I am developing an android app . I am able to send the push notification to app through parse REST API. But I need to send action field ( intent ) in the REST api to open the correct screen . Currently its just opening the home screen .
Now its just opening the home ( main screen ) .How will I be able to specify the intent to open the brand activity class (test.mm.brand) through the parse REST API
My android manifest file is as below.
<activity
android:name=".MofActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="test.mm.brand" />
<activity android:name="test.mm.CustomizedListView" />
<activity android:name="test.mm.HallofFame" />
<activity android:name="test.mm.VideoList" />
REST request
curl -X POST -H "X-Parse-Application-Id: ntItEUY1LZ949R9zfTWDuZORE6dnjICxOni9L9nU" -H "X-Parse-REST-API-Key: dwYZ2DeKutwtswDgWTYkboIw6hRplwSNDR20GiMt" -H "Content-Type: application/json" -d '{ "where": { "deviceType": "android" }, "data": { "alert": "Your suitcase has been filled with tiny robots!", "action": "test.mm.brand", "title" : "dddd" } }' https://api.parse.com/1/push
You need to create a receiver to get the notification as given here Parse Android Notification - responding to payloads
Add this to your manifest
<receiver android:name="test.mm.MyCustomReceiver">
<intent-filter>
<action android:name="test.mm.brand" />
</intent-filter>
</receiver>
Create this class
public class MyCustomReceiver extends BroadcastReceiver {
private static final String TAG = "MyCustomReceiver";
@Override
public void onReceive(Context context, Intent intent) {
try {
String action = intent.getAction();
if(action.equalsIngnoreCase("test.mm.brand") {
Intent intent = new Intent(context, test.mm.brand.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With