简体   繁体   中英

Ionic 3 native plugin of sms not working on my device

I am using Ionic 3 and my device is 4.4.2 android.

Setup:

ionic cordova plugin add cordova-sms-plugin
npm install --save @ionic-native/sms@4

I have add to app.module

import { SMS } from '@ionic-native/sms';

providers: [..., SMS]

home.ts

...
import { SMS } from '@ionic-native/sms';

...
constructor(..., private sms: SMS){}

sendSMS(){
this.sms.send('0030699999999', 'sos')
}

home.html

<button ion-button block (click)="sendSMS()" margin-top color="dark">SMS</button>

I install the apk to my phone with below command:

ionic cordova run android

When I am pressing the button, my app breaks and exit, without sending a message.

I tried to remove platform android and added again, but nothing.

允许通过手机上的应用设置

I had to put a send_sms permission in manifest file (android). Check in my phone v 4.4.2. I didn't check it in iPhone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM