IBM Worklight - 推送通知功能在 Android 模拟器中不起作用 [英] IBM Worklight - Push Notifications feature does not work in Android emulator
问题描述
我正在尝试为 Android 上的 Worklight 推送通知设置示例项目.当我在 Android 模拟器中启动应用程序时,只有前两个按钮(isSubscribed 和 isSupported)是可点击的.其他两个按钮(订阅和取消订阅)保持禁用状态.
I am trying to set up the sample project for Worklight push notification on Android. When I launch the app in the Android emulator only the first two buttons (isSubscribed and isSupported) are clickable. The other two buttons (Subscribe and Unsubscribe) remain disabled.
我的步骤是:
- 将项目导入 Eclipse
- 将 SenderID 和 API 密钥替换为在 application-descriptor.xml 中从 GCM 控制台获取的密钥
- 部署 PushAdapter(包含在项目中)
- 构建和部署
- 在模拟器中启动 Android 应用
缺少什么?
推荐答案
要使推送通知在 Android 模拟器中工作,您需要确保在 Android SDK 管理器中安装:
For Push Notifications to work in the Android Emulator, you need to make sure to install in the Android SDK Manager:
Google API 插件对应于您用于项目的 API 级别(在 Worklight 中,它必须是 API 级别 8 或更高级别).您创建的 AVD 应使用此 Google API
The Google APIs add-on corresponding to the API Level you're using for your project (in Worklight it must be API Level 8 or above). The AVD you create should use this Google API
适用于 Android 的 Google Cloud Messaging 库(在 Extras 类别中可用)
The Google Cloud Messaging for Android Library (available in the Extras category)
注意:Android 模拟器中的推送通知仅在运行 Android OS 4.x.x 的 AVD 中有效.
Note: Push Notifications in the Android Emulator work only in an AVD running Android OS 4.x.x.
接下来,您需要设置 GCM:
无论您使用的是设备还是模拟器,这些步骤都是相关的.
- 创建 Gmail 电子邮件地址
- 转到 GCM 的网页:http://developer.android.com/google/gcm/gs.html
- 点击Google API 控制台页面"
- 如果你从来没有做过上面的第 3 步,你会被要求创建一个项目,这个项目会有一个 ID.此 ID 是您放置在 application-descriptor.xml 中的
- 点击创建新的服务器密钥..."/创建新的 Android 密钥"
- 生成的密钥是您放置在 application-descriptor.xml 中的
API 密钥
值
senderId
值- Create a Gmail email address
- Go to GCM's web page: http://developer.android.com/google/gcm/gs.html
- Click on "Google APIs Console page"
- If you have never done step 3 above, you will be asked to create a project, this project will have an ID. This ID is the
senderId
value you place in application-descriptor.xml - Click on "Create new Server key..." / "Create new Android key"
- The generated key is the
API key
value you place in application-descriptor.xml
现在您需要:
- 构建和部署应用程序
- 部署适配器
- 在设备或模拟器上运行应用
这篇关于IBM Worklight - 推送通知功能在 Android 模拟器中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!