简体   繁体   中英

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

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.

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. 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.

The application ID is: 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". I tried to create a new API Key, but without success.

After reading this: https://stackoverflow.com/a/22453025/6828416 I tried to create a new project on GCM, and it suddenly started to work .

The Docs are currently being updated for GCM, so that will be fixed very soon.

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):

Before:

前

After:

后

Here is how I edited my code snippets after cloning the sample (mock values):

Code Edit 1 Before:

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

Code Edit 1 After:

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

Code Edit 2 Before:

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

Code Edit 2 After:

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:

In my Bluemix config, it looks something like this (mock values):

gcm 凭据

Here's how I got those values from GCM (mock values):

Sender ID:

发件人ID

API Key:

apikey

@Paulo For new projects the dashboard is not coming up to enable GCM API in https://console.developers.google.com . Steps to enable GCM: Create New Project->create API Key->Enable GCM. To Enable GCM please Navigate to Dashboard tab and search for Google Cloud Messaging-> Click on GCM and enable the API. Please wait for 5 min to get it activate.

在此处输入图片说明

Configure the GCM credentials for Push Notification-> register the device and send notification.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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