Shail Adi
Shail Adi

Reputation: 1510

Device is not getting the push notification whereas same code in emulator is getting the push notification using GCM

The application prepared by me is using GCM to get push notifications from the server.

The emulator is getting the push notification but my device is not getting the push notification when I install the same app on the device.

I have provided the SENDER_ID and API Key to the server. The registration Id and device id is sent through the code.

I am fetching the device id using this code :

TelephonyManager telephonyManager1 =(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
device_id = telephonyManager1.getDeviceId();

I am stuck with the problem since last 2 days, but not able to solve it till now. Any help is highly appreciated.

Upvotes: 0

Views: 2044

Answers (2)

Shail Adi
Shail Adi

Reputation: 1510

The issue was solved as the problem was from the server side.

In GCM we do not need to provide the device id. But just the sender id, registration id and api key are needed.

Upvotes: 0

Bhavesh Patadiya
Bhavesh Patadiya

Reputation: 25830

Did you register the device with GCM? for getting the Registration ID you have to do the Following code:

inside onCreate() method, add the following code:

GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);
final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals("")) {
  GCMRegistrar.register(this, SENDER_ID);
} else {
  Log.v(TAG, "Already registered");
}

here you will get regId which you must have to sent it to the Server so that server can send push notification to Device which has the above regId.

for More Help you can refer here

EDITED

you can also refer this Link HERE

Upvotes: 1

Related Questions