I am getting notification in some devices(HTC,Micromax) but some devices are not receiving like Samsung S3. After I have updated my app in google play by adding this code to my existing code.
MainActivity: oncreate:
checkNotNull(SENDER_ID, "SENDER_ID");
GCMRegistrar.checkDevice(getApplicationContext());
GCMRegistrar.checkManifest(getApplicationContext());
regId = GCMRegistrar.getRegistrationId(getApplicationContext());
if (regId.equals(""))
GCMRegistrar.register(getApplicationContext(), SENDER_ID);
else
Log.v(TAG, "Already registered");
GCMIntentservice:
protected void onRegistered(Context context, String registrationId){
dact.new Pushnotification().execute(registrationId);
将此ID发送到服务器端GCMRegistrar.setRegisteredOnServer(context, true);
protected void onMessage(Context context, Intent intent){
String message = intent.getExtras().getString("message");
generateNotification(context, message);
明确许可:
android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.GET_ACCOUNTS
android.permission.WAKE_LOCK
package.permission.C2D_MESSAGE(permission and uses-permission) package.c2dm.permission.RECEIVE
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.epigram.movietalkies" />
<intent-filter>
</receiver>
<service android:name=".GCMIntentService">
Please tell me if there is any mistake in the above code.
Thanks in Advance