我正在为我的 Android 应用程序使用解析推送通知。 我按照教程下载了 jar 文件,然后将其导入到我的项目中,并将这段代码添加到我的 list 中
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
我还添加了 application.class 到我的包中,代码是
public class Application extends android.app.Application {
public Application() {
}
@Override
public void onCreate() {
super.onCreate();
// Initialize the Parse SDK.
Parse.initialize(this, "zzxxxxxxxxxxxxxxVv", "wyxxxxxxxCElxxxxxxx");
// Specify a Activity to handle all pushes by default.
PushService.setDefaultPushCallback(this, MainActivity.class);
// Save the current installation.
ParseInstallation.getCurrentInstallation().saveInBackground();
}
}
在我的主要 Activity 中我这样做
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ParseAnalytics.trackAppOpened(getIntent());
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Log.e("MainActivity", "oncreate");
setContentView(R.layout.activity_main);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
有人说 list 中的应用程序中的名称属性有问题,所以我用我的包名称添加了这一行
<application
android:name="com.test.pushnotificationTest.Application"
在解析仪表板时,当我将应用程序安装到新设备时,我在仪表板中获得了新条目..但是当我尝试发送推送通知时,我没有得到它。 我需要添加广播接收器吗??但它之前使用相同的代码没有广播 帮助我的人
最佳答案
解析 api 有时会滞后于 android 的推送消息传递... 当我签署我的 apk 时,我收到了推送通知。请使用已签署的 apk 再试一次。
关于android - 解析推送通知不适用于 android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18592617/