How to use broadcast reciever to get sent intent from smsmanager (nativescript)
<p>I am using nativescript to build an app that will programmatically send a pre-built text to multiple preset parties in case of emergency.</p>

<p>I have an array of phone numbers and want to iterate over each one, using SMSmanager to send the text and the sentIntent argument <a href="https://developer.android.com/reference/android/telephony/SmsManager.html#getDefault()" rel="nofollow noreferrer">seen in android docs</a> to verify that the text was sent before moving on to the next array item.</p>

<p>I have created the pendingIntent variable to pass into "sms.sendTextMessage" as follows:</p>

<pre><code>var sms = android.telephony.SmsManager.getDefault();
var utils = require("utils/utils");

//Gets application's current state
var context = utils.ad.getApplicationContext();
//Create a replica of Android's intent object
var intent = new android.content.Intent(context, com.tns.NativeScriptActivity.class);

//Create a replica of Android's pendingIntent object using context and intent
var pendingIntent = android.app.PendingIntent.getActivity(context, 1, intent, android.app.PendingIntent.FLAG_UPDATE_CURRENT);
</code></pre>

<p>I then send the text, passing in the pending intent var:</p>

<pre><code>sms.sendTextMessage("5555555555", null, "hello", pendingIntent, null);
</code></pre>

<p>I then attempt to make a basic broadcast receiver using the information I found in the <a href="http://docs.nativescript.org/cookbook/application#registering-a-broadcast-receiver-android" rel="nofollow noreferrer">nativescript docs</a> which should just log something to the console when it recieves the expected data.</p>

<pre><code>app.android.registerBroadcastReceiver(pendingIntent, function() {
        console.log("@@@@@ text sent @@@@@");
    });
</code></pre>

<p>The problem is: nothing happens. I'd expect to get ""@@@@@ text sent @@@@@" logged to the console. I've googled a lot and am thinking maybe I need to add something about this broadcast reciever in the manifest, or perhaps my implimentation is wrong somewhere, but this is my first crack at an android app and I'm at a bit of a loss. Any help would be appreciated.</p>