ParsePushBroadcastReceiver

ParsePushBroadcastReceiver

本文介绍了如何添加"ParsePushBroadcastReceiver.getActivity";到一个应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在应用程序的哪个文件中添加ParsePushBroadcastReceivergetActivity方法?

In which file of an application do I need to add getActivity method of ParsePushBroadcastReceiver?

谢谢.

推荐答案

如果您遵循了像我这样的现有项目的文档,则不建议这样做:

If you followed the documentation for an existing project like me, this is deprecated:

PushService.setDefaultPushCallback(this,YourActivity.class);

PushService.setDefaultPushCallback(this, YourActivity.class);

这对我有用:

实现您的接收器并扩展ParsePushBroadcastReceiver类.

Implement your receiver and extends ParsePushBroadcastReceiver class.

public class Receiver extends ParsePushBroadcastReceiver {

    @Override
    public void onPushOpen(Context context, Intent intent) {

        //To track "App Opens"
        ParseAnalytics.trackAppOpenedInBackground(intent);

        //Here is data you sent
        Log.i(tag, intent.getExtras().getString( "com.parse.Data" ));

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

然后,在您的AndroidManifest.xml中(而不是使用ParsePushBroadcastReceiver)

Then, in your AndroidManifest.xml, (Instead of using ParsePushBroadcastReceiver)

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

这篇关于如何添加"ParsePushBroadcastReceiver.getActivity";到一个应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 12:26