"推送到0 QUOT;在Android的仪表盘解析 [英] "Pushes sent 0" in parse dashboard for android

查看:230
本文介绍了"推送到0 QUOT;在Android的仪表盘解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从parse发送推送通知到Android。而从浏览器发送它的设备的计算正在被正常显示。但推派0被显示在浏览器。

I am trying to send push notifications from parse to android. While sending it from browser the calculations of the devices are being shown properly. But "Pushes sent 0" is being displayed in the browser.

我注册在应用类通知

ParsePush.subscribeInBackground("", new SaveCallback() {
    @Override
    public void done(ParseException e) {
        if (e == null) {
            Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
        } else {
            Log.e("com.parse.push", "failed to subscribe for push", e);
        }
    }
});
ParseInstallation.getCurrentInstallation().saveInBackground();

我也曾在我的Andr​​oid项目中创建的接收

public class PushMessageBroadcast extends ParsePushBroadcastReceiver {

    @Override
    public void onPushOpen(Context context, Intent intent) {
        Log.d("The push","open");
    }

    @Override
    protected Notification getNotification(Context context, Intent intent) {
        // TODO Auto-generated method stub
        return super.getNotification(context, intent);
    }

    @Override
    protected void onPushDismiss(Context context, Intent intent) {
        // TODO Auto-generated method stub
        super.onPushDismiss(context, intent);
    }

    @Override
    protected void onPushReceive(Context context, Intent intent) {
        //here You can handle push before appearing into status e.g if you want to stop it.
        super.onPushReceive(context, intent);
    }
}

我也做了变更清单:

I have also done the changes in manifest:

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

我需要在解析更改任何设置?先谢谢了。

Do I need to change any settings in parse? Thanks in advance.

推荐答案

编辑答案

@ lochana-Tejas的评论后,我意识到,因为我在谷歌开发者控制台云通讯为Android再次被禁用,我的设备反正已经收到了通知,我的答案是不正确的。

After @lochana-tejas comment I realized that my answer was not correct because I disabled again in Google Developer console "Cloud Messaging for Android" and my device had received the notification anyway.

所以,你需要控制的第一件事是,在解析控制台你有这个类的安装这个类有注册一个或多个设备。如果你没有这个类或者是空的推派将为0。

So the first thing you need to control is that in Parse Dashboard you have the class Installation and this class have one or more devices registered. If you don't have this class or is empty "Pushes sent" will be 0.

在这里输入的形象描述

我在这里复制我的code这样你可以比较

I copy my code here so you can compare

  public static void registerParse(Context context) {
        Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);

        Parse.initialize(context, PARSE_APPLICATION_ID, PARSE_CLIENT_KEY);
        ParseInstallation.getCurrentInstallation().saveInBackground();

        ParsePush.subscribeInBackground(PARSE_CHANNEL, new SaveCallback() {
            @Override
            public void done(ParseException e) {
                if (e == null) {
                    Log.d("com.parse.push", "Successfully subscribed to Parse!");
                } else {
                    Log.e("com.parse.push", "failed to subscribe for push", e);
                }
            }
        });
    }

    //This is the user that will be inserted in "Installation class"
    public static void subscribeWithUser(String user) {
        ParseInstallation installation = ParseInstallation.getCurrentInstallation();

        installation.put("user", user);

        installation.saveInBackground(new SaveCallback() {
            @Override
            public void done(ParseException e) {
                if (e == null) {
                    Log.e("subscribeWithUser", "User subscribed successfully!!", e);
                } else {
                    e.printStackTrace();
                    Log.e("subscribeWithUser", "Error to save user", e);
                }
            }
        });


    }

我的清单是这个

        <!-- Added for Parse push notifications -->

        <service android:name="com.parse.PushService" />
        <receiver
            android:name=".receiver.CustomPushReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.USER_PRESENT" />
                <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>
        <receiver
            android:name="com.parse.GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="com.parse.starter" />
            </intent-filter>
        </receiver>
        <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>
        </receiver>   

这篇关于&QUOT;推送到0 QUOT;在Android的仪表盘解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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