Search in sources :

Example 11 with InstanceID

use of com.google.android.gms.iid.InstanceID in project react-native-push-notification by zo0r.

the class RNPushNotificationRegistrationService method onHandleIntent.

@Override
protected void onHandleIntent(Intent intent) {
    try {
        String SenderID = intent.getStringExtra("senderID");
        InstanceID instanceID = InstanceID.getInstance(this);
        String token = instanceID.getToken(SenderID, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
        sendRegistrationToken(token);
    } catch (Exception e) {
        Log.e(LOG_TAG, TAG + " failed to process intent " + intent, e);
    }
}
Also used : InstanceID(com.google.android.gms.iid.InstanceID)

Example 12 with InstanceID

use of com.google.android.gms.iid.InstanceID in project easy by MehdiBenmesa.

the class RegistrationIntentService method onHandleIntent.

@Override
protected void onHandleIntent(Intent intent) {
    String deviceId = intent.getStringExtra("DEVICE_ID");
    String deviceName = intent.getStringExtra("DEVICE_NAME");
    try {
        InstanceID instanceID = InstanceID.getInstance(this);
        String registrationId = instanceID.getToken(getString(R.string.gcm_defaultSenderId), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
        App.getInstance().setGcmToken(registrationId);
        registerDeviceProcess(deviceName, deviceId, registrationId);
        Log.i("token", registrationId);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : InstanceID(com.google.android.gms.iid.InstanceID) IOException(java.io.IOException)

Aggregations

InstanceID (com.google.android.gms.iid.InstanceID)12 IOException (java.io.IOException)7 SharedPreferences (android.content.SharedPreferences)5 Intent (android.content.Intent)4 RequiresApi (android.support.annotation.RequiresApi)1 InvalidJidException (eu.siacs.conversations.xmpp.jid.InvalidJidException)1