【问题标题】:Retrieve "content" of GCM message Intent.检索 GCM 消息 Intent 的“内容”。
【发布时间】:2013-02-22 09:49:16
【问题描述】:

这是从服务器发送消息的方式:

        //Queue Android GCM Notification
        _pushService.QueueNotification(NotificationFactory.AndroidGcm()
            .ForDeviceRegistrationId(device)
            .WithCollapseKey("LATEST")
            .WithJson("{\"alert\":\"" + message + "\",\"badge\":\"7\"}"));

我收到 Intent,如何获取消息?我试过了:

    Log.d(TAG, "" + intent.getStringExtra("{\"alert\":\""));
    Log.d(TAG, "" + intent.getStringExtra("LATEST"));
    Log.d(TAG, "" + intent.getStringExtra("data"));

全部为空,消息文本值的键是什么?

【问题讨论】:

    标签: android android-intent push-notification google-cloud-messaging


    【解决方案1】:

    知道了

    Bundle b = intent.getExtras();
    Set<String> allThatsInThere = b.keySet();
    

    【讨论】:

    • Bundle 没有getKeys() 功能;它应该是keySet()
    猜你喜欢
    • 2020-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-12
    • 1970-01-01
    • 2018-03-20
    相关资源
    最近更新 更多