public class GCMIntentService extends GCMBaseIntentService {
NotificationManager mNotificationManager;
Context cc;
@Override
protected void onRegistered(Context context, String regId) {
Intent intent = new Intent(Constants1.ACTION_ON_REGISTERED);
intent.putExtra(Constants1.FIELD_REGISTRATION_ID, regId);
context.sendBroadcast(intent);
}
@Override
protected void onUnregistered(Context context, String regId) {
Log.i(Constants1.TAG, "onUnregistered: " + regId);
AlertDialog.Builder alert = new AlertDialog.Builder(
getApplicationContext());
alert.show();
}
@Override
protected void onMessage(Context context, Intent intent) {
/**
* You can get the Extras from TaxMann server
*
* Bundle _bundle = intent.getExtras();
*/
String msg = intent.getStringExtra("payload");
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
BackgroundAlert bg = new BackgroundAlert(mNotificationManager, msg);
bg.onReceive(getApplicationContext(), intent);
}
@Override
protected void onError(Context context, String errorId) {
}
}
这是我的 gcm 代码,当我向所有注册设备 ID 发送通知时,我的数据库中有大约 15000 个注册设备 ID 用于通知,然后它显示 10000 个成功和 6000 个不成功。我想从我们的数据库中删除所有 6000 个注册设备 ID,以便它需要收到通知的时间更少。