3

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

3 Answers3

3

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.

Community
  • 1
  • 1
  • Today at a demonstration I had this problem again today @joe - can you help me trying to debug it? – Paulo Felipe Sep 14 '16 at 20:26
  • Sure! If you open a support ticket, we should be able to see more info about your service instance and could potentially do a screensharing session if necessary. – joe Sep 14 '16 at 22:54
1

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:

before

After:

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

service credentials


Here is how I set up GCM:

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

gcm credentials

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

Sender ID:

senderid

API Key:

apikey

joe
  • 2,468
  • 2
  • 12
  • 19
  • Please follow up with me to let me know if this works out for you. If it doesn't, we can do some more debugging. – joe Sep 13 '16 at 22:32
  • Unfortunately it didn't work. I created everything from scratch and I still can't get notifications. ![Screenshot](http://i64.tinypic.com/1euank.jpg). – Paulo Felipe Sep 14 '16 at 01:57
  • I noticed that your API Key was created on May, 3, 2016. @joe Can you please run a new test by creating a new API and a new API Key? I believe Google made some changes to the GCM, and what I get is different from yours. – Paulo Felipe Sep 14 '16 at 03:31
1

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

enter image description here

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

Community
  • 1
  • 1
pradeep sg
  • 193
  • 1
  • 6