我正在尝试在我的 Android 应用程序中使用 GoogleCloudMessaging (GCM) API 进行推送通知。
参考http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/ and http://developer.android.com/google/play-services/setup.html#Setup,我尝试在 AndroidManifest.xml 中设置它们,但它给了我一些错误:
- 无法解析符号“GCMBroadcastReceiver”
- 无法解析符号“GCMintentService”
该块位于应用程序标签中
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<!-- Receives the registration id. -->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.zaqqle.disqover" />
</intent-filter>
</receiver>
<service android:name=".GCMIntentService" />
我正在使用 Android Studio 以及我所做的
- 在 SDK Manager 中安装 Google Play Services 并与 Gradle 同步
- 包括
compile 'com.google.android.gms:play-services:4.3.23'
在构建.gradle
- 包括
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
在AndroidManifest.xml中
你能帮我指出我错过的地方吗?感谢您的帮助!
com.google.android.gcm.GCMBroadcastReceiver
是一个已弃用的类,您的项目中可能没有该类。您应该实现自己的广播接收器。GCMIntentService
是一个你应该实现的类。
您正在使用旧的教程,该教程使用已弃用的类,而不是使用 Google Play 服务库。您应该参考当前的官方 GCM 演示应用程序查看清单的外观以及项目中应包含哪些类。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)