【问题标题】:Push notification not receiving in Galaxy Nexus and Samsung S3 for my Android app在 Galaxy Nexus 和三星 S3 中未收到我的 Android 应用程序的推送通知
【发布时间】:2013-01-06 23:25:44
【问题描述】:

我的 Android 应用程序已经在 Play 商店中上线。现在我已经使用 gcm 更新了带有推送通知的应用程序,因此在 5 台设备(HTC、Micromax、Samsung S3、Galaxy Nexus、Samsung Ace plus)中安装了来自 Play 商店的更新版本。

根据我们的逻辑,所有设备 ID 都存储在服务器端数据库中。这些 id 最终被发送到 GCM 服务器。现在发送推送通知时,我只在 HTC 和 Micromax 中接收。

其他 3 款设备(Samsung S3、Galaxy Nexus、Samsung Ace)有什么问题?

【问题讨论】:

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


    【解决方案1】:

    我不确定您的具体问题是什么,因为您没有提供任何类型的代码。

    但请确保您设备上的 DateTime 日期时间不应该是过去的。因为 GCM 无法同步到过去的日期时间。您必须将其重置为当前日期时间。不确定,但可以尝试一下。可以解决你的问题。

    【讨论】:

    • MainActivity oncreate: checkNotNull(SENDER_ID, "SENDER_ID"); GCMRegistrar.checkDevice(getApplicationContext()); GCMRegistrar.checkManifest(getApplicationContext()); regId = GCMRegistrar.getRegistrationId(getApplicationContext()); if (regId.equals("")) GCMRegistrar.register(getApplicationContext(), SENDER_ID); else Log.v(TAG, "已经注册");
    • GCMIntentservice: @Override protected void onRegistered(Context context, String registrationId) dact.new Pushnotification().execute(registrationId);将此 id 发送到服务器端 GCMRegistrar.setRegisteredOnServer(context, true); protected void onMessage(Context context, Intent intent) { String message = intent.getExtras().getString("message");生成通知(上下文,消息); }
    • 清单权限:android.permission.INTERNET android.permission.ACCESS_NETWORK_STATE android.permission.WRITE_EXTERNAL_STORAGE android.permission.GET_ACCOUNTS android.permission.WAKE_LOCK package.permission.C2D_MESSAGE(permission and uses-permission) 包。 c2dm.permission.RECEIVE
    【解决方案2】:

    Android 3.1 或更高版本,在用户打开您的应用至少一次之前,您的应用不会收到任何广播。

    http://developer.android.com/about/versions/android-3.1.html#launchcontrols

    【讨论】:

    • 系统将 FLAG_EXCLUDE_STOPPED_PACKAGES 添加到所有广播意图中。这样做是为了防止来自后台服务的广播无意或不必要地启动已停止应用程序的组件。 [...] 应用程序在首次安装但尚未启动以及由用户手动停止时(在管理应用程序中)处于停止状态。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-11
    • 1970-01-01
    • 2015-12-06
    相关资源
    最近更新 更多