简体   繁体   English

适用于 android 的 Bluemix 推送通知未发送任何通知

[英]Bluemix push notification for android is not sending any notifications

I'm trying to use the sample code available here: https://github.com/ibm-bluemix-mobile-services/bms-samples-android-hellopush我正在尝试使用此处提供的示例代码: https : //github.com/ibm-bluemix-mobile-services/bms-samples-android-hellopush

And the first difficulty I found was on configuring the GCM - it seems that somethings changed since it was documented - anyway I guess I got everything configured correctly.我发现的第一个困难是配置 GCM - 自从它被记录以来,似乎有些事情发生了变化 - 无论如何,我想我已经正确配置了所有内容。

I got the app working and I'm able to register my device, but there is no notification when I try to send it.我让应用程序运行起来,我可以注册我的设备,但是当我尝试发送它时没有通知。 I'm using both the bluemix dashboard and the swagger to send a message.我同时使用 bluemix 仪表板和 swagger 来发送消息。 The response I get is that the message was sent, but I got nothing on the device (a mobile phone, not the emulator).我得到的回应是消息已发送,但我在设备(手机,而不是模拟器)上什么也没有。

I checked my Google API dashboard, and there is no activity on the GCM api.我检查了我的 Google API 仪表板,GCM api 上没有活动。

The application ID is: f97eb706-3375-438d-8221-cd7ac0266de1应用ID为:f97eb706-3375-438d-8221-cd7ac0266de1

I was using Postman to test the GCM API ( https://android.googleapis.com/gcm/send ) and I was getting an "Error 401 Unauthorized".我正在使用 Postman 来测试 GCM API ( https://android.googleapis.com/gcm/send ) 并且我收到“错误 401 未经授权”。 I tried to create a new API Key, but without success.我试图创建一个新的 API 密钥,但没有成功。

After reading this: https://stackoverflow.com/a/22453025/6828416 I tried to create a new project on GCM, and it suddenly started to work .读完这篇: https : //stackoverflow.com/a/22453025/6828416我尝试在 GCM 上创建一个新项目,它突然开始工作

The Docs are currently being updated for GCM, so that will be fixed very soon.目前正在为 GCM 更新文档,因此很快就会修复。

I attempted to recreate your problem and just tested out the sample with Push Notifications with the Android sample here (with the latest version of Android Studio v2.1.3):我试图重新创建您的问题,并在此处使用 Android 示例(使用最新版本的 Android Studio v2.1.3)测试了带有推送通知的示例:

Before:前:

前

After:后:

后

Here is how I edited my code snippets after cloning the sample (mock values):以下是我在克隆示例(模拟值)后编辑代码片段的方式:

Code Edit 1 Before:代码编辑 1 之前:

BMSClient.getInstance().initialize(this, "<APPLICATION_ROUTE>", "<APPLICATION_ID>", BMSClient.REGION_US_SOUTH);

Code Edit 1 After:代码编辑 1 之后:

BMSClient.getInstance().initialize(this, "http://imfpush.ng.bluemix.net", "dfadsfadsfdsf-2343-2334-8e82-421c02ce847c", BMSClient.REGION_US_SOUTH);

Code Edit 2 Before:代码编辑 2 之前:

push.initialize(this, "<APPLICATION_ID>", "<CLIENT_SECRET>");

Code Edit 2 After:代码编辑 2 之后:

push.initialize(this, "dfadsfadsfdsf-2343-2334-8e82-421c02ce847c", "edec64df-34fd-44e3-9d1e-dfsfsdf989899");

I got these values from the Push Notifications service credentials (mock values).我从推送通知服务凭据(模拟值)中获得了这些值。

服务凭证


Here is how I set up GCM:这是我设置 GCM 的方法:

In my Bluemix config, it looks something like this (mock values):在我的 Bluemix 配置中,它看起来像这样(模拟值):

gcm 凭据

Here's how I got those values from GCM (mock values):以下是我从 GCM 获取这些值的方法(模拟值):

Sender ID:发件人ID:

发件人ID

API Key: API 密钥:

apikey

@Paulo For new projects the dashboard is not coming up to enable GCM API in https://console.developers.google.com . @Paulo 对于新项目,仪表板不会在https://console.developers.google.com 中启用 GCM API。 Steps to enable GCM: Create New Project->create API Key->Enable GCM.启用 GCM 的步骤:创建新项目->创建 API 密钥->启用 GCM。 To Enable GCM please Navigate to Dashboard tab and search for Google Cloud Messaging-> Click on GCM and enable the API.要启用 GCM,请导航到仪表板选项卡并搜索 Google Cloud Messaging-> 单击 GCM 并启用 API。 Please wait for 5 min to get it activate.请等待 5 分钟以使其激活。

在此处输入图片说明

Configure the GCM credentials for Push Notification-> register the device and send notification.为推送通知配置 GCM 凭据-> 注册设备并发送通知。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM