Git Product home page Git Product logo

nativescript-phone's Introduction

npm npm

NativeScript Phone

NativeScript plugin to use the device phone and SMS features for Android and iOS

Native Info

Installation

Install the plugin using the NativeScript CLI

tns plugin add nativescript-phone

Breaking Change with 3.x.x

Version 3.x.x and later uses an event system to dispatch events for the handling of success, failure, errors for the SMS and Dial methods. See the snippets below for the correct usage of the event emitter system.

Video Tutorial

egghead plugin lesson @ https://egghead.io/lessons/javascript-using-the-device-phone-and-sms-with-nativescript

Android

To dial the phone without user interaction on Android your app must request permission to dial. The following must be in your app's AndroidManifest.xml.

<uses-permission android:name="android.permission.CALL_PHONE" />

IOS

You must add the following line to your project's Info.plist

<key>LSApplicationQueriesSchemes</key>
<array>
   <string>tel</string>
   <string>telprompt</string>
</array>

Usage

To use the phone module you must first require() it from your project's node_modules directory:

var phone = require('nativescript-phone');

After you have a reference to the module you can then call the available methods.

Methods

dial: initiate a phone call

Parameters
  • telNum: Phone number to dial.
  • prompt: Boolean to enable OS specific confirmation before dialing.

For example, the code below dials the number without showing the device specific confirmation prompt:

// my-page.js
var phone = require('nativescript-phone');
phone.dial('212-555-1234', false);

sms: open the OS specific SMS app

Parameters
  • smsNum: SMS number or numbers to use.
  • messageText: String to send.

For example, the code below opens the sms app for the provided number:

Send to one number (provided for backwards compatibility)

// my-page.js

import {
  NSPhoneEventEmitter,
  sms,
  dial,
  requestCallPermission,
  SMSEvents,
  DialEvents
} from 'nativescript-phone';

NSPhoneEventEmitter.on(SMSEvents.FAILED, args => {
  console.log('FAILED', args.data);
});

NSPhoneEventEmitter.on(SMSEvents.SUCCESS, args => {
  console.log('SMS Successful');
});

NSPhoneEventEmitter.on(SMSEvents.CANCELLED, args => {
  console.log('SMS Cancelled');
});

NSPhoneEventEmitter.on(SMSEvents.ERROR, args => {
  console.log('SMS ERROR', args.data);
});

NSPhoneEventEmitter.on(SMSEvents.UNKNOWN, args => {
  console.log('SMS UNKNOWN', args.data);
});

sms(['212-555-1234'], 'testing');

Send to multiple numbers

import { sms } from 'nativescript-phone';
// Use the event system to listen for failure, success, cancelled, error events

sms(['212-555-1234', '212-555-1245'], 'My Message');

requestCallPermission: Request Android Call_Phone Permission

Parameters

  • explanation: The explanation text if the user denies permission twice (nullable). If you attempt to use dial("122929912", false) to not prompt on android 6.0, nothing will happen unless permission has been approved before. When this method is executed, a check for permissions happens, and a promise is returned. If the user refuse it, you can handle it via the catch method of promise. If it accepts you can dial in the thenmethod. You should so "wrap" your dial method inside of the requestCallPermission() method (see following example).

TypeScript example

import {
  NSPhoneEventEmitter,
  sms,
  dial,
  requestCallPermission,
  SMSEvents,
  DialEvents
} from 'nativescript-phone';

NSPhoneEventEmitter.on(SMSEvents.ERROR, args => {
  console.log('SMS ERROR', args.data);
});

NSPhoneEventEmitter.on(SMSEvents.UNKNOWN, args => {
  console.log('SMS UNKNOWN', args.data);
});

/// Dial a phone number.
function callHome() {
  const phoneNumber = '415-123-4567';
  requestCallPermission(
    'You should accept the permission to be able to make a direct phone call.'
  )
    .then(() => dial(phoneNumber, false))
    .catch(() => dial(phoneNumber, true));
}

// Text a number (or multiple numbers)
function messageParents() {
  sms(['212-555-1234', '212-555-0987'], 'Text till your fingers bleed');
}

nativescript-phone's People

Contributors

bradmartin avatar bthurlow avatar dlcole avatar domgaud avatar fpaaske avatar jcassidyav avatar kielsoft avatar mathieutu avatar msc-miguel avatar msywensky avatar rajivnarayana avatar tgpetrov avatar witi83 avatar yezarela avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nativescript-phone's Issues

Gettting {response : cancelled} Event after message was sent successfully

I am sending SMSes using TNS and ng2 on an Android 6.0 device.

Here is the code

permissions.requestPermission(android.Manifest.permission.SEND_SMS, "I need these permissions because I'm cool")
        .then(function() {
          TNSPhone.sms(['987654321'], "Text till your fingers bleed")
                .then((args:any) => {
                    console.log(JSON.stringify(args));
                }, (err) => {
                    console.log('Error: ' + err);
                });
        .catch(function() {
            console.log("Uh oh, no permissions - plan B time!");
        });

The above code is executed on the tap event of a button. So when the button is tapped, the native SMS app opens up, where the number and text message is pre-filled. I just hit the send button and the message is sent.

All good till now.

But I do not get any output in the success callback.

Moreover, after the message has been sent. I close the native SMS app, which takes me back to my app. i get the following.

JS: {"response":"cancelled"}

This means that in the promise the success callback is executed.

Is there a way to get the success in the args response of the success callback.

Not working on iOS

This is working well as expected on Android.

I have a problem on iOS. I have put as much details below as possibly hoping someone can help me resolve this?

Project: Using angular 2/nativescript

ios Info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>en</string>
	<key>CFBundleDisplayName</key>
	<string>Savvy</string>
	<key>CFBundleExecutable</key>
	<string>${EXECUTABLE_NAME}</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>${PRODUCT_NAME}</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>1.0</string>
	<key>CFBundleSignature</key>
	<string>????</string>
	<key>CFBundleVersion</key>
	<string>1.0</string>
	<key>LSRequiresIPhoneOS</key>
	<true/>
	<key>UILaunchStoryboardName</key>
	<string>LaunchScreen</string>
	<key>UIRequiresFullScreen</key>
	<true/>
	<key>UIRequiredDeviceCapabilities</key>
	<array>
		<string>armv7</string>
	</array>
	<key>UISupportedInterfaceOrientations</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
	<key>UISupportedInterfaceOrientations~ipad</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationPortraitUpsideDown</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
	<key>NSAppTransportSecurity</key>  
	<dict>  
		<key>NSAllowsArbitraryLoads</key>
		<true />  
	</dict>
	<key>NSCalendarsUsageDescription</key>
    <string>${PRODUCT_NAME} calendar use</string>
	<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>tel</string>
		<string>telprompt</string>
	</array>
</dict>
</plist>

html
<Label class="font-awesome medium-spacing" text="&#xf095;" (tap)="makeCall()"></Label>

component

var phone = require( "nativescript-phone" );
makeCall () {
    phone.dial("01234567890",false);
  }

error on console:

-canOpenURL: failed for URL: "tel://01234567890" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

UIDataDetectorTypeLegacyPhoneNumber is incompatible with other types

Hello,

I recently noticed that I am getting the following error in the console:

UIDataDetectorTypeLegacyPhoneNumber is incompatible with other types

Strangely enough, the app works as expected and I can use the the plugin without any issues. The error are logged in the console when I access a page that does not use the plugin. It gets logged 4 times.

I contacted Telerik and they suggested that it might be related to your plugin so I thought I would post this here as well. Please see http://stackoverflow.com/questions/41106893/nativescript-ios-error for more details.

Have you seen this error before and what can I do to correct it?

Thank you.

Feature Request: Read SMS

A great addition would be the ability to read SMS from a particular sender id.

This will be useful for user verification for reading One Time Passwords.

[Android] sms() doesn't use default app

If you switch the default messaging app to Textra or similar, the sms()-method will be "stuck" on this and continue to use this app even if you switch the default messaging app back to the stock messaging app that came with the phone.

According to this link it's recommended to use ACTION_SENDTO instead of ACTION_VIEW to send messages.

iOS 10 Xcode8 compatibility

With the release of iOS 10 and Xcode 8 the dial function doesn't work.
There have been some changes in the iOS sdk from using methods to properties.
So you will need to change UIApplication.sharedApplication().canOpenURL() and openURL() from using the old method to using the properties.

I simply changed from using UIApplication.sharedApplication() to utils.ios.getter(UIApplication, UIApplication.sharedApplication) in the index.ios.js file and the function now works. Not sure if this is a proper fix, but thought it might lead you in the right direction for a permanent resolve.

Could you create a new release on NPM

Hello,

It could be really great if you can do a new release of the nativescript-phone on NPM with the latest PR/Commits. Because it contains some fix and without it if i'm adding this library it break my code.

Thanks for you for your work :)

Error LSApplicationQueriesSchemes

I am trying to make a button, by clicking on which a mobile number will be called. The fact is that when compiling to a real device, an error occurs in the console:

Error detected during LiveSync on [UUID] for /Users/andrey/Desktop/rentride-apps/rentride-black/rrblack. Error: Unexpected key "LSApplicationQueriesSchemes" while parsing <dict/>.

This happened after I added the following code, according to the plugin instructions.

<key>LSApplicationQueriesSchemes</key> <array> <string>tel</string> <string>telprompt</string> </array>

What could be the reason?

I use:

  • Client Sidekick
  • Real device iPhone XR iOS 12

TNS doctor:
✔ Your ANDROID_HOME environment variable is set and points to correct directory.
✔ Your adb from the Android SDK is correctly installed.
✔ The Android SDK is installed.
✔ A compatible Android SDK for compilation is found.
✔ Javac is installed and is configured properly.
✔ The Java Development Kit (JDK) is installed and is configured properly.
✔ Xcode is installed and is configured properly.
✔ xcodeproj is installed and is configured properly.
✔ CocoaPods are installed.
✔ CocoaPods update is not required.
✔ CocoaPods are configured properly.
✔ Your current CocoaPods version is newer than 1.0.0.
✔ Python installed and configured correctly.
✔ The Python 'six' package is found.
✔ Xcode version 10.2.1 satisfies minimum required version 9.
✔ Getting NativeScript components versions information...
✔ Component nativescript has 5.4.2 version and is up to date.
✔ Component tns-core-modules has 5.4.3 version and is up to date.
✔ Component tns-android has 5.4.0 version and is up to date.
✔ Component tns-ios has 5.4.2 version and is up to date.

Dial not working on iOS and SMS not working on Android 6+

I noticed that sms doesn't work on Android 6 , but both dial and sms work on Android 5 (and under)

I'm catching the following exception when try to phone.sms([number], message) on Android 6:

:Error: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW typ=vnd.android-dir/mms -sms (has extras) } JS: android.app.Instrumentation.checkStartActivityResult(Instrumentation.jav a:1798) JS: android.app.Instrumentation.execStartActivity(Instrumentation.java:1512) JS: android.app.Activity.startActivityForResult(Activity.java:3930) JS: android.app.Activity.startActivityForResult(Activity.java:3890) JS: com.tns.Runtime.callJSMethodNative(Native Method) JS: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:861) JS: com.tns.Runtime.callJSMethodImpl(Runtime.java:726) JS: com.tns.Runtime.callJSMethod(Runtime.java:712) JS: com.tns.Runtime.callJSMethod(Runtime.java:693) JS: com.tns.Runtime.callJSMethod(Runtime.java:683) JS: com.tns.gen.android.view.View_OnClickListener.onClick(View_OnClickListen er.java:11) JS: android.view.View.performClick(View.java:5204) JS: android.view.View$PerformClick.run(View.java:21155) JS: android.os.Handler.handleCallback(Handler.java:739) JS: android.os.Handler.dispatchMessage(Handler.java:95) JS: android.os.Looper.loop(Looper.java:148) JS: android.app.ActivityThread.main(ActivityThread.java:5422) JS: java.lang.reflect.Method.invoke(Native Method) JS: com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.ja va:726) JS: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Any suggestions?

SMS works but phone calls doesn't on android

SMS works but phone calls doesn't on android, when setting the second parameter of the call function to false

var phone = require( "nativescript-phone" );
phone.dial("212-555-1234",false);

Dial not working on iOS with TNS v5.3.1

Dial not working on iOS with TNS v5.3.1

import * as phone from 'nativescript-phone';
phone.dial(String(this.data.phone), true);

Nothing happens and no error thrown. My Info.plist:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>tel</string>
    <string>telprompt</string>
</array>

Versions

  • TNS cli 5.3.0
  • package.json tns-ios 5.3.1
  • nativescript-phone 1.4.0

Shipped ES6 code breaks --uglify build

It appears using es6's optional function parameter breaks the webpack's --uglify build.
I tracked it down to this function declaration.

function dial(telNum, prompt = true)

tns --version 3.1.1
tns-core-modules 3.1.0
tns-android 3.1.1
nativescript-phone 1.3.0

[Android] ignores default SMS application

Hi, first of all, thanks for awesome plugin.

I have an issue on Android. The plugin opens the preinstalled SMS application, but I have selected Hangouts as default SMS app.

This wouldn't matter as much, but since this factory default SMS app is "disabled", it won't let me send the message, unless I change it to the default one.

Hopefully screenshots will make it easier to understand.

Prompt for default app change:
screenshot_20170112-164918

Disabled send button:
screenshot_20170112-164927

Not working on Android emulator or device

If i call phone.dial( "2125551212", false) - that works - the dialer pops up with the right tel#.

If I call without the 2nd parameter as true - it returns false - I can't look at the exception because it's trapped in the module.

I'm trying this in a {N} project with typescript. I've edited the master manifest file and added 3 permissions.

<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.SEND_SMS"/>

Getting "No v4 support" and permission issue in Nativescript 6 version

Hi I am using this plugin in nativescript v6 but when I called the method to call on number I am getting this error

JS: No v4 support
JS: No v4 support
JS: Error: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxxxx cmp=com.android.server.telecom/.components.UserCallActivity } from ProcessRecord{75bfe7d 17305:org.nativescript.phcc/u0a482} (pid=17305, uid=10482) with revoked permission android.permission.CALL_PHONE
JS:     android.os.Parcel.createException(Parcel.java:1950)
JS:     android.os.Parcel.readException(Parcel.java:1918)
JS:     android.os.Parcel.readException(Parcel.java:1868)
JS:     android.app.IActivityManager$Stub$Proxy.startActivity(IActivityManager.java:3668)
JS:     android.app.Instrumentation.execStartActivity(Instrumentation.java:1856)
JS:     android.app.Activity.startActivityForResult(Activity.java:4605)
JS:     androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:676)
JS:     android.app.Activity.startActivityForResult(Activity.java:4563)
JS:     androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:663)
JS:     android.app.Activity.startActivity(Activity.j...

I have already added the permission to ANDROID in AndroidManifest.xml file and IOS in info.plist file

Do not require phone feature

Hi there!

I have a button in my app which allows to dial a phone number (I use it with system confirm prompt). My app cannot be installed on any Android tablet because they don't have the phone feature.

Is it possible to not require phone feature with this plugin? Thanks for your help :)

Crash on xcode simulator

When I run my app on a real phone it works perfectly. When I run it on the simulator it crashes every time.

2020-03-11 12:21:04.970916+0000 rrmobile[17954:234015] *** JavaScript call stack:
(
0 extend@[native code]
1 ../node_modules/nativescript-phone/index.js@file:///app/vendor.js:165556:67
2 webpack_require@file:///app/runtime.js:75:34
3 ./app/shared/alert-detail/alert-detail.component.ts@file:///app/1.js:144:96
4 webpack_require@file:///app/runtime.js:75:34
5 ./app/shared/alert-detail/alert-detail.module.ts@file:///app/1.js:602:100
6 webpack_require@file:///app/runtime.js:75:34
7 ./app/pages/alerts/alerts.module.ts@file:///app/12.js:58:121
8 webpack_require@file:///app/runtime.js:75:34
9 webpack_require@[native code]
10 onInvoke@file:///app/vendor.js:64364:39
11 @file:///app/vendor.js:90372:49
12 @file:///app/vendor.js:91117:37
13 onInvokeTask@file:///app/vendor.js:64355:43
14 @file:///app/vendor.js:90422:57
15 drainMicroTaskQueue@file:///app/vendor.js:90829:42
16 promiseReactionJob@:1:11
17 UIApplicationMain@[native code]
18 run@file:///app/vendor.js:92561:26
19 @file:///app/vendor.js:86830:26
20 @file:///app/vendor.js:86731:38
21 @file:///app/vendor.js:86711:26
22 ./main.ts@file:///app/bundle.js:2978:116
23 webpack_require@file:///app/runtime.js:75:34
24 checkDeferredModules@file:///app/runtime.js:44:42
25 webpackJsonpCallback@file:///app/runtime.js:31:39
26 anonymous@file:///app/bundle.js:2:61
27 evaluate@[native code]
28 moduleEvaluation@:1:11
29 @:2:1
30 asyncFunctionResume@:1:11
31 @:24:9
32 promiseReactionJob@:1:11
)
2020-03-11 12:21:04.971369+0000 rrmobile[17954:234015] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Class "MFMessageComposeViewController" referenced by type encoding not found at runtime.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23c4f02e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff50b97b20 objc_exception_throw + 48
2 NativeScript 0x00000001092d7280 _ZN12NativeScript11TypeFactory9parseTypeEPNS_12GlobalObjectERPKN8Metadata12TypeEncodingEb + 6016
3 NativeScript 0x00000001092d7d79 _ZN12NativeScript11TypeFactory10parseTypesEPNS_12GlobalObjectERPKN8Metadata12TypeEncodingEib + 329
4 NativeScript 0x00000001092bcb42 _ZN12NativeScript17ObjCMethodWrapper14finishCreationERN3JSC2VMEPNS_12GlobalObjectEN3WTF7HashSetIPKN8Metadata10MemberMetaENS6_7PtrHashISB_EENS6_10HashTraitsISB_EEEE + 594
5 NativeScript 0x00000001092a631a _ZN12NativeScript17ObjCMethodWrapper6createERN3JSC2VMEPNS_12GlobalObjectEPNS1_9StructureEN3WTF7HashSetIPKN8Metadata10MemberMetaENS8_7PtrHashISD_EENS8_10HashTraitsISD_EEEE + 362
6 NativeScript 0x00000001092bee68 _ZN12NativeScript23overrideObjcMethodCallsEPN3JSC9ExecStateEPNS0_8JSObjectENS0_12PropertyNameEPNS0_6JSCellEPKN8Metadata13BaseClassMetaENS8_10MemberTypeEP10objc_classRKN3WTF6VectorIPKNS8_12ProtocolMetaELm0ENSF_15CrashOnOverflowELm16EEE + 1272
7 NativeScript 0x00000001092ac1c1 _ZN12NativeScript16ObjCClassBuilder17addInstanceMethodEPN3JSC9ExecStateERKNS1_10IdentifierEPNS1_6JSCellE + 369
8 NativeScript 0x00000001092b21d0 _ZN12NativeScript16ObjCClassBuilder18addInstanceMembersEPN3JSC9ExecStateEPNS1_8JSObjectENS1_7JSValueE + 9264
9 NativeScript 0x00000001092b6474 _ZN12NativeScript18ObjCExtendFunctionEPN3JSC9ExecStateE + 6148
10 ??? 0x00002bc37b20116b 0x0 + 48118584316267
11 NativeScript 0x0000000109cb810f llint_entry + 93226
12 ??? 0x00002bc37b211f37 0x0 + 48118584385335
13 NativeScript 0x0000000109cb810f llint_entry + 93226
14 ??? 0x00002bc37b211f37 0x0 + 48118584385335
15 NativeScript 0x0000000109cb810f llint_entry + 93226
16 ??? 0x00002bc37b211f37 0x0 + 48118584385335
17 NativeScript 0x0000000109cb810f llint_entry + 93226
18 ??? 0x00002bc37b211f37 0x0 + 48118584385335
19 NativeScript 0x0000000109ca133b vmEntryToJavaScript + 200
20 NativeScript 0x00000001093729dc _ZN3JSC11Interpreter11executeCallEPNS_9ExecStateEPNS_8JSObjectENS_8CallTypeERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 460
21 NativeScript 0x0000000109b3eabb _ZN3JSC4callEPNS_9ExecStateENS_7JSValueENS_8CallTypeERKNS_8CallDataES2_RKNS_7ArgListE + 59
22 NativeScript 0x00000001099844f7 _ZN3JSC17boundFunctionCallEPNS_9ExecStateE + 695
23 ??? 0x00002bc37b20116b 0x0 + 48118584316267
24 ??? 0x00002bc37b658776 0x0 + 48118588868470
25 ??? 0x00002bc37b69fce2 0x0 + 48118589160674
26 ??? 0x00002bc37b782628 0x0 + 48118590088744
27 ??? 0x00002bc37b72fcf7 0x0 + 48118589750519
28 ??? 0x00002bc37b6ed338 0x0 + 48118589477688
29 ??? 0x00002bc37b9cc095 0x0 + 48118592487573
30 ??? 0x00002bc37b207712 0x0 + 48118584342290
31 NativeScript 0x0000000109ca133b vmEntryToJavaScript + 200
32 NativeScript 0x00000001093729dc _ZN3JSC11Interpreter11executeCallEPNS_9ExecStateEPNS_8JSObjectENS_8CallTypeERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 460
33 NativeScript 0x0000000109b3ece4 _ZN3JSC12profiledCallEPNS_9ExecStateENS_15ProfilingReasonENS_7JSValueENS_8CallTypeERKNS_8CallDataES3_RKNS_7ArgListE + 196
34 NativeScript 0x00000001099e282c _ZN3JSC11JSMicrotask3runEPNS_9ExecStateE + 492
35 NativeScript 0x000000010924a6b2 _ZN12NativeScript12GlobalObject15drainMicrotasksEv + 178
36 NativeScript 0x00000001092477a1 _ZN12NativeScriptL33microtaskRunLoopSourcePerformWorkEPv + 33
37 CoreFoundation 0x00007fff23bb2221 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
38 CoreFoundation 0x00007fff23bb214c __CFRunLoopDoSource0 + 76
39 CoreFoundation 0x00007fff23bb1924 __CFRunLoopDoSources0 + 180
40 CoreFoundation 0x00007fff23bac62f __CFRunLoopRun + 1263
41 CoreFoundation 0x00007fff23babe16 CFRunLoopRunSpecific + 438
42 GraphicsServices 0x00007fff38438bb0 GSEventRunModal + 65
43 UIKitCore 0x00007fff4784fb48 UIApplicationMain + 1621
44 NativeScript 0x0000000109cc2c1d ffi_call_unix64 + 85
45 ??? 0x0000000113645020 0x0 + 4620308512
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

Class "MFMessageComposeViewController" referenced by type encoding not found at runtime.

Hi,

I get this error after updating my test phone to iOS 14.5 Beta, and it happens when we use sms() somewhere in the code.
Could you help with fixing this?

  "dependencies": {
    "@nativescript/core": "~6.5.20",
    "nativescript-phone": "^2.0.0",
import * as Phone from "nativescript-phone";
Phone.sms(['99999999'], 'Hello').then(r => console.log('sms')); // removing this line resolves the issue

You don't even have to actually call the method, it's enough to just have it in the code. The app will crash during startup.
This is the error I get:

default	13:43:21.395615+0100	demo	*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Class "MFMessageComposeViewController" referenced by type encoding not found at runtime.'
*** First throw call stack:
(0x19fbd7060 0x1b3e69460 0x1013e0934 0x1013e1090 0x1013c8498 0x1013b3e50 0x1013ca2d8 0x1013b942c 0x1013be83c 0x1013c1628 0x101f037cc 0x101f00f28 0x101f00f28 0x101f00e80 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00e80 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00e80 0x101f00e80 0x101f00e80 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101ee25e8 0x101490e48 0x101b915f4 0x101c1273c 0x101c02ee4 0x1017a64d4 0x101ef0080 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101f00f28 0x101ee25e8 0x101490e48 0x101ba7e20 0x101f037cc 0x101f00f28 0x101ee25e8 0x101490e48 0x1013cb8e8 0x1013cb2f4 0x1013cc428 0x101f37388 0x101f381b4 0x1<…>
default	13:43:21.395834+0100	demo	NativeScript caught signal 6.
default	13:43:21.395931+0100	demo	Native Stack:
default	13:43:21.396105+0100	demo	1   0x1013db018 sig_handler(int)
default	13:43:21.396192+0100	demo	2   0x1e8117d9c <redacted>
default	13:43:21.396280+0100	demo	3   0x1e81279c4 pthread_kill
default	13:43:21.396399+0100	demo	4   0x1a8d40a44 abort
default	13:43:21.396591+0100	demo	5   0x1b3f43be8 <redacted>
default	13:43:21.396744+0100	demo	6   0x1b3f35d14 <redacted>
default	13:43:21.396830+0100	demo	7   0x1b3e49960 <redacted>
default	13:43:21.397017+0100	demo	8   0x1b3f43074 <redacted>
default	13:43:21.397106+0100	demo	9   0x1b3f4599c __cxa_get_exception_ptr
default	13:43:21.397316+0100	demo	10  0x1b3f4595c <redacted>
default	13:43:21.397464+0100	demo	11  0x1b3e69588 objc_exception_rethrow
default	13:43:21.397696+0100	demo	12  0x1013e0934 NativeScript::TypeFactory::parseType(NativeScript::GlobalObject*, Metadata::TypeEncoding const*&, bool)
default	13:43:21.397835+0100	demo	13  0x1013e1090 NativeScript::TypeFactory::parseTypes(NativeScript::GlobalObject*, Metadata::TypeEncoding const*&, int, bool)
default	13:43:21.397896+0100	demo	14  0x1013c8498 NativeScript::ObjCMethodWrapper::finishCreation(JSC::VM&, NativeScript::GlobalObject*, WTF::HashSet<Metadata::MemberMeta const*, WTF::PtrHash<Metadata::MemberMeta const*>, WTF::HashTraits<Metadata::MemberMeta const*> >)
default	13:43:21.397950+0100	demo	15  0x1013b3e50 NativeScript::ObjCMethodWrapper::create(JSC::VM&, NativeScript::GlobalObject*, JSC::Structure*, WTF::HashSet<Metadata::MemberMeta const*, WTF::PtrHash<Metadata::MemberMeta const*>, WTF::HashTraits<Metadata::MemberMeta const*> >)
default	13:43:21.398036+0100	demo	16  0x1013ca2d8 NativeScript::overrideObjcMethodCalls(JSC::ExecState*, JSC::JSObject*, JSC::PropertyName, JSC::JSCell*, Metadata::BaseClassMeta const*, Metadata::MemberType, objc_class*, WTF::Vector<Metadata::ProtocolMeta const*, 0ul, WTF::CrashOnOverflow, 16ul> const&)
default	13:43:21.398161+0100	demo	17  0x1013b942c NativeScript::ObjCClassBuilder::addInstanceMethod(JSC::ExecState*, JSC::Identifier const&, JSC::JSCell*)
default	13:43:21.398217+0100	demo	18  0x1013be83c NativeScript::ObjCClassBuilder::addInstanceMembers(JSC::ExecState*, JSC::JSObject*, JSC::JSValue)
default	13:43:21.398272+0100	demo	19  0x1013c1628 NativeScript::ObjCExtendFunction(JSC::ExecState*)
default	13:43:21.398425+0100	demo	20  0x101f037cc llint_entry
default	13:43:21.398544+0100	demo	21  0x101f00f28 llint_entry
default	13:43:21.398605+0100	demo	22  0x101f00f28 llint_entry
default	13:43:21.398655+0100	demo	23  0x101f00e80 llint_entry
default	13:43:21.398708+0100	demo	24  0x101f00f28 llint_entry
default	13:43:21.398758+0100	demo	25  0x101f00f28 llint_entry
default	13:43:21.398799+0100	demo	26  0x101f00f28 llint_entry
default	13:43:21.398843+0100	demo	27  0x101f00e80 llint_entry
default	13:43:21.398920+0100	demo	28  0x101f00f28 llint_entry
default	13:43:21.399158+0100	demo	29  0x101f00f28 llint_entry
default	13:43:21.399219+0100	demo	30  0x101f00f28 llint_entry
default	13:43:21.399281+0100	demo	31  0x101f00e80 llint_entry
default	13:43:21.399343+0100	demo	JS Stack:
default	13:43:21.399451+0100	demo	extend([native code])
at ../node_modules/nativescript-phone/index.js(file:///app/vendor.js:54103:67)
at __webpack_require__(file:///app/runtime.js:751:34)
at fn(file:///app/runtime.js:121:39)
at file:///app/bundle.js:394:95
at ./main-view-model.ts(file:///app/bundle.js:536:34)
at __webpack_require__(file:///app/runtime.js:751:34)
at fn(file:///app/runtime.js:121:39)
at file:///app/bundle.js:327:93
at ./main-page.ts(file:///app/bundle.js:362:34)
at __webpack_require__(file:///app/runtime.js:751:34)
at fn(file:///app/runtime.js:121:39)
at webpackContext(file:///app/bundle.js:166:28)
at loader(file:///app/vendor.js:7089:35)
at loadModule(file:///app/vendor.js:7130:39)
at file:///app/vendor.js:15179:75
at file:///app/vendor.js:22594:57
at valueChanged(file:///app/vendor.js:23026:23)
at file:///app/vendor.js:17062:37
at setPropertyValue(file:///app/vendor.js:15869:17)
at file:///app/vendor.js:15829:33
at getComponentModule(file:///app/vendor.js:15841:29)
at file:///app/vendor.js:15587:62
at file:///app/ve<…>

Plugin Not Working

This plugin does not seem to work for me, I am integrating this plugin in my angular2 + typescript project and I am able to import the module from node_modules also have added the required permission inside my AndroidMainifest file but the call is not initiated when I call the dial function, no error is thrown but still nothing happens I have tried on both emulator and phone.

Plugin drops leading 0

Hi, i cannot send an sms to a number with a zero appended to it ("087 541 4778").

As soon as the sms app opens up it removes the 0.

Phone.dial not work on Android 6.0+ if set prompt's value to false

I don't sure this is normal behavior or not.

I use phone.dial('xxxxxx', false). It works well on iOS. But for Android it just does nothing. I also noticed that even prompt's value set to false, iOS still pop up the confirmation dialog before make a call.

It works on Android when I set prompt's value to true. Android opened the phone intent and let user to confirm before make a call.

At the moment, I understand that prompt's value is ignored by the latest version of both OS. Is it correct?

Problem when dial within Observable.subscribe

I have an angular Directive to make phone dial. My code is as following :

@HostListener('tap')
    callPhone() {
        this.userService.getUserPhone(this.userUid)
            .subscribe(p => {
                TNSPhone.dial(String(p), true);
            });
    }

This code does not work and an JS: [object Object] is printed on the console.

However, the code below works

@HostListener('tap')
    callPhone() {
                TNSPhone.dial(String(p), true);
    }

How can I deal with that ?

Can't add as a Nativescript Library...

When i try to add nativescript-phone to my app as a library, i type the new style
tns plugin add nativescript-phone
it fails and outputs:
nativescript-phone is not a valid NativeScript plugin. Verify that the plugin pa ckage.json file contains a nativescript key and try again.

I think
"nativescript": { "platforms": { "android": "1.4.0", "ios": "1.4.0" } }
part is missing in package.json

Accessing own phone number

Hi,

Does this plugin allow reading own phone #? On iOS phone # is available in phone/contacts which makes me think that it can be accessed (not sure for Android). I would like to get user's phone # (asking the user for permission is OK) and populate a textfield with it.

phone.sms prevents access to contacts

After using phone.sms to send a text, my app never receives control back from contacts.getContact. I've created a small sample app at https://github.com/dlcole/contactTester that demos the problem. You can tap the 'Get Contact' button as much as you want and it works as expected. Tap the 'Send Text' button once, though, and now 'Get Contact' does not return. This leads me to believe the nativescript-phone plugin is the culprit.

I've also created this SO post to document the problem: https://stackoverflow.com/questions/61309828/nativescript-phone-prevents-nativescript-contacts-from-returning.

Android fails if number doesn't contain "#"

Current Setup
-Nativescript 3.4.1
-TNS Android 3.4.1
-Angular 5.2.1
-webpack, snapshot, uglified, not

Line 28 in the index.android.js fails with the following error
"TypeError: telNum.replace is not a function"

WARNING: The file: ...../node_modules/nativescript-phone/platforms/android/AndroidManifest.xml

Hi first of all thank you for this awesome plugin, I've just got into deploy and I receive this warning:

WARNING: The file: ..../node_modules/nativescript-phone/platforms/android/AndroidManifest.xml is depricated, you can read more about what will be the expected plugin structure here: https://www.nativescript.org/blog/migrating-n-android-plugins-from-version-1.7-to-2.0

It might me nice to swap the structure.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.