简体   繁体   English

为Android设置解析推送通知

[英]Set Up Parse Push Notifications for Android

I am trying to set up push notifications for Android using Parse and I can't seem to get past initializing it within the application. 我正在尝试使用Parse为Android设置推送通知,我似乎无法在应用程序中初始化它。

I think I might be missing something. 我想我可能会遗漏一些东西。

I get the error message 我收到错误消息

java.lang.RuntimeException: Unable to start activity ComponentInfo{package_name/...MainActivity}: java.lang.IllegalArgumentException: Must subscribe to channel with a valid icon identifier.

but i don't know what 'Must subscribe to channel with a valid icon identifier' means. 但我不知道'必须订阅带有效图标标识符的频道'是指。 I have tried a few different channel names and callback activities. 我尝试了一些不同的频道名称和回调活动。

public class GlobalState extends Application {

    private static final String PARSE_APP_ID = ...;
    private static final String PARSE_CLIENT_KEY = ...;

    public void onCreate() {

        Parse.initialize(this, PARSE_APP_ID, PARSE_CLIENT_KEY);

        // Enable the Parse push notification service for remote pushes.
        PushService.subscribe(this, "channel", MainActivity.class);
        PushService.setDefaultPushCallback(this, MainActivity.class);

    }
}

I would really appreciate any help! 我真的很感激任何帮助!

I FIGURED IT OUT 我想到了

i finally took the error message literally: 我终于从字面上理解了错误信息:

Must subscribe to channel with a valid icon identifier.

and i was missing android:icon="@drawable/ic_launcher" attribute from the <application> field in the AndroidManifest.xml file. 我在AndroidManifest.xml文件的<application>字段中缺少android:icon =“@ drawable / ic_launcher”属性。 once i added it, notifications worked fine. 一旦我添加它,通知工作正常。 seems really obvious in hindsight 事后看来真的很明显

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM