解析推送通知在 android 上不起作用 [英] Parse Push Notification not work on android

查看:26
本文介绍了解析推送通知在 android 上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的 android 应用程序使用解析推送通知.我按照教程下载了 jar 文件,然后将其导入到我的项目中,并且我已将此代码添加到我的清单中

I am using parse push notification for my android app. I follow tutorial and i downlaod jar file and than import it into my project and i have added this code into my manifest

<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 添加到我的包中,代码为

Also i have added application.class into my my package and code is

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();
    }
}

在我的主要活动中,我这样做

In my main activity i do this

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

有人说清单中的应用程序中的名称属性有问题,所以我用我的pacakge名称添加了这一行

Some says that it problem with name attribut in application in manifest so i aaded this line wiht my pacakge name

 <application
    android:name="com.test.pushnotificationTest.Application"

在我将应用程序安装到新设备时解析仪表板,而不是在仪表板中获得新条目.但是当我尝试发送推送通知时,我没有收到.我需要添加广播接收器吗??但它以前在没有广播的情况下使用相同的代码工作帮帮我

In parse dashboard when i install app into new device than i get new entry into dashboard..but when i try to send push notification i dont get it. Do i need to add brodcast receiver?? but it was working before with same code without broadcast help me guys

推荐答案

parse api 有时会滞后于 Android 的推送消息传递...我在签署我的 apk 时收到推送通知.. 使用已签名的 apk 再试一次.

parse api sometimes lags for push message delivery for android... i got push notification when i signed my apk.. try it again with signed apk.

这篇关于解析推送通知在 android 上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆