Parse.com: Get Pushnotification on onPushOpen

In my android app I am using push notifications provided by Parse.com. I got this working successfully, however my app has multiple push notifications and different actions should load depending on which click was clicked. I was expecting to get the push notification message from the onPushOpen intent parameter, but it seems empty ?, Does anyone know how I can get the message in the onPushOpen method ?.

In some context, I've added my current PushReceiver code below.

public class PushReceiver extends ParsePushBroadcastReceiver {

    @Override
    public void onPushOpen(Context context, Intent intent) {
        Log.e("Push", "Clicked");
        Intent i = new Intent(context, Splash.class);
        i.putExtras(intent.getExtras());
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(i);
    }
}

      

Thank.

+3


source to share


1 answer


Make sure you upgrade to Parse-1.8.2.

Then you also need to do two more things.

  • Add info to your AndroidManifest.xml (inside)

    <service android:name="com.parse.PushService" />
    <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...ADD_PACKAGE_INFO_HERE..." />
        </intent-filter>
    </receiver>
    
    <receiver android:name="com..ADD_PACKAGE_INFO_HERE....PushReceiver"
              android:exported="false">
        <intent-filter>
            <action android:name="com.parse.push.intent.RECEIVE" />
            <action android:name="com.parse.push.intent.DELETE" />
            <action android:name="com.parse.push.intent.OPEN" />
        </intent-filter>
    </receiver>
    
          

  • Add this to AndroidManifest.xml outside of tags

  • In the cloud code on Parse.com, set the broadcast uri to "com .... ADD_PACKAGE_INFO_HERE ... PushReceiver"



NB: # 1 and # 2 should be provided to you in a debug trace when you start your Android app.

Hope this helps. I spent hours trying to get this to work and the key updated to 1.8.2 for me.

EDIT: You should also look at overriding onReceive as well as onPushOpen ... which actually triggers the notification. Good luck.

0


source







All Articles