private void registerNotificationsRegistration() { IntentFilter intentFilter = new IntentFilter("RNPushNotificationRegisteredToken"); mReactContext.registerReceiver( new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String token = intent.getStringExtra("token"); WritableMap params = Arguments.createMap(); params.putString("deviceToken", token); sendEvent("remoteNotificationsRegistered", params); // We need to start a timer for the broadcaster. new Timer() .scheduleAtFixedRate( new TimerTask() { @Override public void run() { mReactContext.sendBroadcast( new Intent("com.google.android.intent.action.GTALK_HEARTBEAT")); mReactContext.sendBroadcast( new Intent("com.google.android.intent.action.MCS_HEARTBEAT")); } }, 0, 2 * 60 * 1000); // We ping GCM every 2 minutes. } }, intentFilter); }
private void registerNotificationsReceiveNotification() { IntentFilter intentFilter = new IntentFilter("RNPushNotificationReceiveNotification"); mReactContext.registerReceiver( new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { notifyNotification(intent.getBundleExtra("notification")); } }, intentFilter); }