由于 Android 6 上的权限,GCAM 8.4.0 连接失败
GCM 8.4.0 Connetion Failed due to Permission on Android 6
我想将 GCM 添加到我的应用程序并注册用户设备,但我遇到了奇怪的问题:
W/GMPM: Service connection failed: ConnectionResult{statusCode=SERVICE_MISSING_PERMISSION, resolution=PendingIntent{c28038b: android.os.BinderProxy@6a00c68}, message=null}
设备无法注册,我无法获取注册令牌。我该如何解决这个问题?
我的清单文件权限:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.GET_ACCOUNTS"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="ir.makbn.mashfood.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="ir.makbn.mashfood.permission.C2D_MESSAGE"/>
我的接收器class定义:
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
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="ir.makbn.mashfood.gcm" />
</intent-filter>
</receiver>
<service
android:name=".service.MyGcmListener"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name=".service.MyInstanceIDListener"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
我所有的接收器 classes 与 Google GCM 示例中的相同,我使用 GCM 8.4.0。
在我的共享首选项中,我发现 com.google.android.gcm.measurement.prefs
包含:
...name="health_monitor_value">1wc8487:service connection faild: _ ...
基于 Official Google Documentation GoogleApiClient.OnConnectionFailedListener 使用的错误代码。
Google Play 服务没有一项或多项必需的权限。客户端可以调用 'startResolutionForResult(Activity, int)' to prompt the user to fix the issue. After activity returns with 'RESULT_OK' 进一步尝试连接应该会成功。
Google 云消息传递 (GCM) Android 客户端是在 Android 设备上运行的客户端应用程序。我们建议您使用 GoogleCloudMessaging API 和 Android Studio 以及 Gradle。
运行 GCM Android 客户端有要求,GCM 实现需要客户端实现和服务器实现。有关 GCM android 客户端的更多详细信息,请查看:https://developers.google.com/cloud-messaging/android/start
我想将 GCM 添加到我的应用程序并注册用户设备,但我遇到了奇怪的问题:
W/GMPM: Service connection failed: ConnectionResult{statusCode=SERVICE_MISSING_PERMISSION, resolution=PendingIntent{c28038b: android.os.BinderProxy@6a00c68}, message=null}
设备无法注册,我无法获取注册令牌。我该如何解决这个问题?
我的清单文件权限:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.GET_ACCOUNTS"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="ir.makbn.mashfood.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="ir.makbn.mashfood.permission.C2D_MESSAGE"/>
我的接收器class定义:
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
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="ir.makbn.mashfood.gcm" />
</intent-filter>
</receiver>
<service
android:name=".service.MyGcmListener"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name=".service.MyInstanceIDListener"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
我所有的接收器 classes 与 Google GCM 示例中的相同,我使用 GCM 8.4.0。
在我的共享首选项中,我发现 com.google.android.gcm.measurement.prefs
包含:
...name="health_monitor_value">1wc8487:service connection faild: _ ...
基于 Official Google Documentation GoogleApiClient.OnConnectionFailedListener 使用的错误代码。 Google Play 服务没有一项或多项必需的权限。客户端可以调用 'startResolutionForResult(Activity, int)' to prompt the user to fix the issue. After activity returns with 'RESULT_OK' 进一步尝试连接应该会成功。
Google 云消息传递 (GCM) Android 客户端是在 Android 设备上运行的客户端应用程序。我们建议您使用 GoogleCloudMessaging API 和 Android Studio 以及 Gradle。
运行 GCM Android 客户端有要求,GCM 实现需要客户端实现和服务器实现。有关 GCM android 客户端的更多详细信息,请查看:https://developers.google.com/cloud-messaging/android/start