msywensky / nativescript-phone

MIT License
72 stars 29 forks source link

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

Closed prantikv closed 3 years ago

prantikv commented 7 years ago

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.

Adam95 commented 7 years ago

+1 any progress on this? I got to the same situation.

bradmartin commented 7 years ago

I believe this will always be the result for android currently.

The plugin would need to be improved and have a ContentObserver added to monitor and track the message if it is sent. The result will always be cancelled because the SMS application has been closed (cancelled).

prashantnirgun commented 5 years ago

does anyone find or fix this issue ?

fpaaske commented 4 years ago

Also looking for a fix for this issue.

fpaaske commented 3 years ago

This issue was solved for us with the new event based method in v3.x, ref #51