IBM Worklight - 推送通知功能在 Android 模拟器中不起作用 [英] IBM Worklight - Push Notifications feature does not work in Android emulator

查看:29
本文介绍了IBM Worklight - 推送通知功能在 Android 模拟器中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 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.

我的步骤是:

  1. 将项目导入 Eclipse
  2. 将 SenderID 和 API 密钥替换为在 application-descriptor.xml 中从 GCM 控制台获取的密钥
  3. 部署 PushAdapter(包含在项目中)
  4. 构建和部署
  5. 在模拟器中启动 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:
无论您使用的是设备还是模拟器,这些步骤都是相关的.

  1. 创建 Gmail 电子邮件地址
  2. 转到 GCM 的网页:http://developer.android.com/google/gcm/gs.html
  3. 点击Google API 控制台页面"
  4. 如果你从来没有做过上面的第 3 步,你会被要求创建一个项目,这个项目会有一个 ID.此 ID 是您放置在 application-descriptor.xml
  5. 中的 senderId
  6. 点击创建新的服务器密钥..."/创建新的 Android 密钥"
  7. 生成的密钥是您放置在 application-descriptor.xml 中的 API 密钥
  1. Create a Gmail email address
  2. Go to GCM's web page: http://developer.android.com/google/gcm/gs.html
  3. Click on "Google APIs Console page"
  4. 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
  5. Click on "Create new Server key..." / "Create new Android key"
  6. The generated key is the API key value you place in application-descriptor.xml

现在您需要:

  1. 构建和部署应用程序
  2. 部署适配器
  3. 在设备或模拟器上运行应用

这篇关于IBM Worklight - 推送通知功能在 Android 模拟器中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆