Discontinued setDefaultPushCallback and trackAppOpened methods

Asked

Viewed 90 times

3

While using Parse, I noticed that some methods used in PARSE’s own site examples are discontinued (deprecated), among them the PushService.setDefaultPushCallback and the ParseAnalytics.trackAppOpened. Does anyone know how these methods were replaced?

1 answer

1

The method ParseAnalytics.trackAppOpened(getIntent()), generally used in the OnCreate has been replaced by the ParseAnalytics.trackAppOpenedInBackground(getIntent()). Already the method PushService.setDefaultPushCallback, used within the application class (extends Application) did not have a method to replace it, but rather an implementation of the class ParsePushBroadcastReceiver, 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 by the class you want to call when opening the notification.

Now, finally, the Ardroidmanifest:

Where 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 gets:

<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 substitution of methods deprecated.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.