Reputation: 213
I'm trying to make a receiver to extract the text from the push notification powered by Parse.com, I receive the notification but it looks like my BroadcastReceiver isn't called, as the Log.d isn't logging
my MainActivity.java onCreate()
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Parse.initialize(this, "-", "-"); //removed keys for question
PushService.setDefaultPushCallback(this, MainActivity.class);
ParseAnalytics.trackAppOpened(getIntent());
}
my Manifest.xml receivers
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver
android:name="com.example.parsepushnotificationreceiver.MyCustomReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.example.parsepushnotificationreceiver.UPDATE_STATUS" />
</intent-filter>
</receiver>
<receiver
android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.example.parsepushnotificationreceiver" />
</intent-filter>
</receiver>
my BroadcastReceiver class
@Override
public void onReceive(Context context, Intent intent) {
try {
String action = intent.getAction();
String channel = intent.getExtras().getString("com.parse.Channel");
JSONObject json = new JSONObject(intent.getExtras().getString(
"com.parse.Data"));
Log.d(TAG, "got action " + action + " on channel " + channel
+ " with:");
Iterator itr = json.keys();
while (itr.hasNext()) {
String key = (String) itr.next();
Log.d(TAG, "..." + key + " => " + json.getString(key));
}
} catch (JSONException e) {
Log.d(TAG, "JSONException: " + e.getMessage());
}
}
}
my package is
package com.example.parsepushnotificationreceiver;
Thank you,
SOLUTION:
got it working, the idea was in the json object being sen it self, template {"action": "com.example.parsepushnotificationreceiver.UPDATE_STATUS", "name": "Vaughn", "newsItem": "Man bites dog"}
Upvotes: 2
Views: 484
Reputation: 213
SOLUTION:
got it working, the idea was in the json object being sen it self, template {"action": "com.example.parsepushnotificationreceiver.UPDATE_STATUS", "name": "Vaughn", "newsItem": "Man bites dog"}
Upvotes: 0