SetDefaultPushCallback (Context, Class <? Extends Activity>) method of type PushService is deprecated
The whole problem I am facing is this line of code
PushService.setDefaultPushCallback (this, MainActivity.class);
when importing PushService, setDefaultPushCallback | () is deprecated. Why is this happening. I get notifications but the Faucet app crashes. Also don't receive when the app is down.
source to share
I found a solution and it's pretty simple.
I found the same question
fooobar.com/questions/140527 / ...
"After spending a few hours. Found a solution: Implement your receiver and extend the ParsePushBroadcastReceiver class.
Receiver.java
public class Receiver extends ParsePushBroadcastReceiver {
@Override
public void onPushOpen(Context context, Intent intent) {
Log.e("Push", "Clicked");
Intent i = new Intent(context, HomeActivity.class);
i.putExtras(intent.getExtras());
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
Use it in your manifest (instead of using ParsePushBroadcastReceiver)
Code for project manifest:
<receiver
android:name="your.package.name.Receiver"
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>
"Credits to @Ahmad Raza
source to share
From Parse documentation on onPushOpen ():
Called when a user opens a push notification. Sends analytics information back to Parse so that the app can be opened from this push notification. By default, this will trigger the action returned by ParsePushBroadcastReceiver. getActivity (context, intent). If push contains a "uri" parameter, the Intent is fired to view that URI with the activity returned by ParsePushBroadcastReceiver.getActivity (android.content.Context, android.content.Intent) on the background stack.
So, if you override onPushOpen (), then no analytics will be sent.
So here's my code:
public class Receiver extends ParsePushBroadcastReceiver {
@Override
protected Class<? extends Activity> getActivity(Context context, Intent intent) {
return HomeActivity.class;
}
}
You need to register the receiver like in the above post.
Tested with Parse 1.10.3
source to share