Search code examples
javascriptsmstitaniumtitanium-mobile

Titanium pre-populate SMS body


I'm opening the native SMS composer in Android and want to pre-populate the SMS body. I tried...

Titanium.Platform.openURL('sms:?body=hello world!');

....but it adds hello world! to the contact field. Is there any way to add to the body?


Solution

  • for android, you can use intent to send sms...

    Example

    var intent = Ti.Android.createIntent({
            action : Ti.Android.ACTION_VIEW,
            type : 'vnd.android-dir/mms-sms',
        });
        intent.putExtra('sms_body', <body text>);
        intent.putExtra("address", <number>);
        try {
            Ti.Android.currentActivity.startActivity(intent);
        } catch (ActivityNotFoundException) {
            Ti.UI.createNotification({
                message : "Error"
            }).show();
        }
    

    and for iphone you can use this module to send sms.