Push failure browser notifications end up on android

I use Parse for push notifications in android, but it eventually falls into the background when I turn off Wi-Fi.

this gives me an error:

java.lang.RuntimeException: Cannot start the receiver com.parse.ParseBroadcastReceiver: java.lang.RuntimeException: applicationContext is null. Before using the Parse library, you must call Parse.initialize (context, applicationId, clientKey).

here is my code

public class ParseBroadcastReceiverCustom extends BroadcastReceiver { @Override public void onReceive(final Context context, Intent intent) { if(intent == null) return; ConnectionDetector connection = new ConnectionDetector(context); if (connection.isNetworkAvailable()) { PushService.startServiceIfRequired(context); } } } 

and in the manifest file

  <receiver android:name="com.parse.ParsePushBroadcastReceiver" 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> 

and main activities onCreate

  ConnectionDetector connection = new ConnectionDetector(this); if (connection.isNetworkAvailable()) { PushService.setDefaultPushCallback(this, RegisterForget.class); } 

any help please

+2
source share
2 answers
  • PushService completely deprecated with the new APIs you have enabled by declaring ParsePushBroadcastReceiver in your manifest. You can read about the changes to click on the blogpost ad.
  • Your answer is in the error message itself. Call Parse.initialze. Your onCreate activity should have Parse.initialize(this, "YOUR APPLICATION ID", "YOUR CLIENT KEY"); If you put this code in an action, and not in your application, Android can disable your application due to inactivity, and then resume it using the push intent, not your launch activity, in which case you will not call Parse.intialize .
+2
source

I followed this tutorial step by step and now it works https://parse.com/tutorials/android-push-notifications

0
source

All Articles