gpt4 book ai didi

Android GCM 一些设备没有注册

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:54:40 24 4
gpt4 key购买 nike

我在 Google Play 中有一个应用程序的下载量为 5000。

在这 5000 个中,有 900 个未能在我的服务器上存储 GCM 注册 ID。

我担心 18% 的失败率,并且正在努力找出发生这种情况的原因。将 Id 传递到我的服务器并存储绝对不是问题,因此我认为这一定是注册失败。有没有人在他们的项目中遇到过这样的事情?代码如下:

// Fired every time the app is booted in Main Activity
private void setupGCM()
{
String gcmRegId = GCMRegistrar.getRegistrationId(this);
if (gcmRegId.equals(""))
{
GCMRegistrar.register(this, AppProperties.GCM_SENDER_ID);
} else
{
// This is well tested and is not the issue
ServerUtils.sUpdatePushToken(this, gcmRegId);
}
}

// GCMIntentService Class onRegistered
@Override
protected void onRegistered(Context context, String registrationId)
{
mContext = context;
if (!registrationId.equals(""))
{
AppProperties.GCM_REGISTRATION_ID = registrationId;
new UpdateGCMRegistrationIdAsync().execute();
} else
{
GCMRegistrar.setRegisteredOnServer(context, false);
}
}

// GCMIntentService Class My Async class for updating Reg Id
private class UpdateGCMRegistrationIdAsync extends AsyncTask<Integer, Integer, Void>
{
@Override
protected Void doInBackground(Integer... params)
{
ServerUtils.sUpdatePushToken(mContext, AppProperties.GCM_REGISTRATION_ID);
return null;
}
}

最佳答案

我刚刚处理了一个可能与您的问题相同的问题。 Android 低于 4.1 的设备无法向 GCM 注册。这是我在 android-gcm 谷歌组的帖子:

Ok, got it solved. Thanks to J.Carlos Navea and Mark Murphy in this thread:
https://groups.google.com/forum/?fromgroups=#!searchin/android-gcm/onRegister/android-gcm/CqMRN4gVRpY/AGphcX1AuhgJ

The issue was the <category> tag in the receiver declaration. It is required for anything less than 4.1
Use your package name there. Additionally, check to make sure that the <permission> and <uses-permission>
tags use the same string/name. I was getting away with that one as well on 4.1

关于Android GCM 一些设备没有注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15276033/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com