2

Currently I'm using the following code to display the message composer, but it opens the native iOS message app and my application goes to background.

Titanium.Platform.openURL('sms:'+e.rowData.value);

But I want to show the message composer inside my application.

Is there any way to display the message composing window of iOS in my titanium application ?

I searched a lot but didn't get any solution. And there is nothing in the appcelerator documentation regarding the message composer.

Thanks in advance

Midhun MP
  • 103,496
  • 31
  • 153
  • 200
  • I tried with the Post share by Rahul. Ti.Platform.openURL('sms://' +123456789 + '&body=' + encodeURIComponent("Test Message")); Worked for me too. – Darshana Patil Jun 06 '17 at 14:33
  • @DarshanaPatil: Are you sure that the solution provided will open the message window inside our own app ? Or just it open up the message app of iOS system ? – Midhun MP Jun 06 '17 at 18:37

3 Answers3

3

I have better solution without using module

Ti.Platform.openURL('sms://' +Your_phone_number + '&body=' + encodeURIComponent(MESSAGE_IN_STRING));

It worked for me.

rahul.sapkal23
  • 707
  • 9
  • 15
1

Try this,

var SMS = require('ti.sms');
var sms = SMS.createSMSDialog({
    animated: true
});
sms.barColor = 'black';
sms.toRecipients = [
    '5678309' // who should receive the text? put their numbers here!
];
sms.messageBody = 'This is a text message.';
sms.addEventListener('complete', function(evt) {
    if (evt.success) {
        alert('SMS sent!');
    }
    else {
        switch (evt.result) {
            case SMS.CANCELLED:
                alert('User cancelled SMS!');
                break;
            case SMS.FAILED:
            default:
                alert(evt.error);
                break;
        }
    }
});
sms.open();
DJB
  • 857
  • 7
  • 15
  • This won't work, because you are using any other module other than titanium for displaying the message window (That's why you are using require('ti.sms')) – Midhun MP Dec 26 '12 at 11:01
  • Is it possible to select a contact from your list rather than prepopulate a phone nr? – CyberJunkie Apr 14 '14 at 01:40
1

Currently(January 1st 2013) no built-in modules available in Titanium SDK to integrate native iOS SMS view to Titanium application. There are a lot of third party modules for doing this.

  1. TiSMSDialog
  2. benCoding.SMS

Also I developed a module for doing this, You can find it here MMP_SMS.

Midhun MP
  • 103,496
  • 31
  • 153
  • 200