The deprecated setDefaultPushCallback and trackAppOpened methods

3

When using Parse, I noticed that some of the methods used in the PARSE site examples are deprecated, including PushService.setDefaultPushCallback and ParseAnalytics.trackAppOpened . Anyone know how to replace these methods?

    
asked by anonymous 26.11.2014 / 17:49

1 answer

1

The ParseAnalytics.trackAppOpened(getIntent()) method, generally used in OnCreate , has been replaced by the ParseAnalytics.trackAppOpenedInBackground(getIntent()) method. However, the PushService.setDefaultPushCallback method used within the application class ( extends Application ) did not have a method to override it, but rather an implementation of the ParsePushBroadcastReceiver class, as follows in the example below:

public class Receiver extends ParsePushBroadcastReceiver {
    @Override
    public void onPushOpen(Context context, Intent intent){
        Log.e("Push", "Aberto");

        Intent i = new Intent(context, MainActivity.class);
        i.putExtras(intent.getExtras());
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(i);
    }
}

Create this class, remembering to replace MainActivity.class with the class you want to call when you open the notification.

Now, finally, you should change the ArdroidManifest :

Where it was:

<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>

Now it stays:

<receiver
        android:name="pacote.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>

This is the replacement of the deprecated methods.

    
26.11.2014 / 17:49