com.google.firebase.iid.FirebaseInstanceId Java Examples

The following examples show how to use com.google.firebase.iid.FirebaseInstanceId. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RefreshFirebaseInstanceIdTask.java    From chat21-android-sdk with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected Void doInBackground(Object... params) {
    try {
        FirebaseInstanceId.getInstance().deleteInstanceId();
        Log.i(DEBUG_LOGIN, "RefreshFirebaseInstanceIdTask.doInBackground: instanceId deleted with success.");

        // Now manually call onTokenRefresh()
        Log.d(DEBUG_LOGIN, "RefreshFirebaseInstanceIdTask.doInBackground: Getting new token");
        String token = FirebaseInstanceId.getInstance().getToken();
        Log.i(TAG_TOKEN, "RefreshFirebaseInstanceIdTask: token == " + token);

    } catch (IOException e) {
        Log.e(DEBUG_LOGIN, "RefreshFirebaseInstanceIdTask.doInBackground: deleteInstanceIdCatch: " + e.getMessage());
    }

    return null;
}
 
Example #2
Source File: FirebaseInstanceIDService.java    From weMessage with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void onTokenRefresh() {
    if (isServiceRunning(ConnectionService.class)){
        final ConnectionServiceConnection serviceConnection = new ConnectionServiceConnection();

        Intent intent = new Intent(this, ConnectionService.class);
        bindService(intent, serviceConnection, Context.BIND_IMPORTANT);

        serviceConnection.scheduleTask(new Runnable() {
            @Override
            public void run() {
                serviceConnection.getConnectionService().getConnectionHandler().updateRegistrationToken(FirebaseInstanceId.getInstance().getToken());
                unbindService(serviceConnection);
            }
        });
    }
}
 
Example #3
Source File: FcmActivity.java    From stitch-android-sdk with Apache License 2.0 6 votes vote down vote up
public void register(final View view) {
  toggleDisabled();

  // get a client
  final StitchAppClient client = Stitch.getDefaultAppClient();

  // get the push client
  final FcmServicePushClient pushClient =
      client.getPush().getClient(FcmServicePushClient.factory, GCM_SERVICE_NAME);

  pushClient.register(FirebaseInstanceId.getInstance().getToken())
      .addOnCompleteListener(new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull final Task<Void> task) {
          if (!task.isSuccessful()) {
            Log.e(TAG, "failed to register for push notifications", task.getException());
            toggleDeregistered();
            return;
          }
          Log.i("stitch", "registered for push notifications!");
          toggleRegistered();
        }
      });
}
 
Example #4
Source File: Home.java    From UberClone with MIT License 6 votes vote down vote up
private void updateFirebaseToken() {
    FirebaseDatabase db=FirebaseDatabase.getInstance();
    final DatabaseReference tokens=db.getReference(Common.token_tbl);

    final Token token=new Token(FirebaseInstanceId.getInstance().getToken());
    if(FirebaseAuth.getInstance().getUid()!=null) tokens.child(FirebaseAuth.getInstance().getUid()).setValue(token);
    else if(account!=null) tokens.child(account.getId()).setValue(token);
    else{
        GraphRequest request = GraphRequest.newMeRequest(
                accessToken,
                new GraphRequest.GraphJSONObjectCallback() {
                    @Override
                    public void onCompleted(JSONObject object, GraphResponse response) {
                        String id = object.optString("id");
                        tokens.child(id).setValue(token);
                    }
                });
        request.executeAsync();
    }
}
 
Example #5
Source File: DriverHome.java    From UberClone with MIT License 6 votes vote down vote up
private void updateFirebaseToken() {
    FirebaseDatabase db=FirebaseDatabase.getInstance();
    final DatabaseReference tokens=db.getReference(Common.token_tbl);

    final Token token=new Token(FirebaseInstanceId.getInstance().getToken());
    if(FirebaseAuth.getInstance().getUid()!=null) tokens.child(FirebaseAuth.getInstance().getUid()).setValue(token);
    else if(account!=null) tokens.child(account.getId()).setValue(token);
    else{
        GraphRequest request = GraphRequest.newMeRequest(
                accessToken,
                new GraphRequest.GraphJSONObjectCallback() {
                    @Override
                    public void onCompleted(JSONObject object, GraphResponse response) {
                        String id = object.optString("id");
                        tokens.child(id).setValue(token);
                    }
                });
        request.executeAsync();
    }
}
 
Example #6
Source File: ProCommand.java    From Telephoto with Apache License 2.0 6 votes vote down vote up
@Override
public boolean execute(Message message, Prefs prefs) {
    Long chatId = message.chat().id();
    Prefs.UserPrefs userPrefs = prefs.getUser(message.from().id());
    if (userPrefs != null) {
        StringBuilder result = new StringBuilder();
        result.append(botService.getString(R.string.pro_step_1));
        result.append(botService.getString(R.string.pro_step_2));
        result.append(botService.getString(R.string.pro_step_3));
        result.append(botService.getString(R.string.pro_step_4));


        try {
            String token = FirebaseInstanceId.getInstance().getToken();
            result.append("\nSerial 1: ").append(token).append("\n");
            result.append("\nSerial 2: ").append(Build.SERIAL);
        } catch (Throwable ex) {
            L.e(ex);
        }

        telegramService.sendMessage(chatId, result.toString());
    } else {
        telegramService.sendMessage(chatId, "Incorrect user!");
    }
    return false;
}
 
Example #7
Source File: LogoutHelper.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
public static void signOut(GoogleApiClient mGoogleApiClient, FragmentActivity fragmentActivity) {
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if (user != null) {
        ProfileInteractor.getInstance(fragmentActivity.getApplicationContext())
                .removeRegistrationToken(FirebaseInstanceId.getInstance().getToken(), user.getUid());

        for (UserInfo profile : user.getProviderData()) {
            String providerId = profile.getProviderId();
            logoutByProvider(providerId, mGoogleApiClient, fragmentActivity);
        }
        logoutFirebase(fragmentActivity.getApplicationContext());
    }

    if (clearImageCacheAsyncTask == null) {
        clearImageCacheAsyncTask = new ClearImageCacheAsyncTask(fragmentActivity.getApplicationContext());
        clearImageCacheAsyncTask.execute();
    }
}
 
Example #8
Source File: MyFirebaseInstanceIDService.java    From LNMOnlineAndroidSample with Apache License 2.0 6 votes vote down vote up
@Override
public void onTokenRefresh() {
    super.onTokenRefresh();
    String refreshedToken = FirebaseInstanceId.getInstance().getToken();

    // Saving reg id to shared preferences
    storeRegIdInPref(refreshedToken);

    // sending reg id to your server
    sendRegistrationToServer(refreshedToken);

    // Notify UI that registration has completed, so the progress indicator can be hidden.
    Intent registrationComplete = new Intent(REGISTRATION_COMPLETE);
    registrationComplete.putExtra("token", refreshedToken);
    LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}
 
Example #9
Source File: LoginPresenter.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
public void checkIsProfileExist(final String userId) {
    ProfileManager.getInstance(context).isProfileExist(userId, exist -> {
        ifViewAttached(view -> {
            if (!exist) {
                view.startCreateProfileActivity();
            } else {
                PreferencesUtil.setProfileCreated(context, true);
                ProfileInteractor.getInstance(context.getApplicationContext())
                        .addRegistrationToken(FirebaseInstanceId.getInstance().getToken(), userId);
            }

            view.hideProgress();
            view.finish();
        });
    });
}
 
Example #10
Source File: FirebaseMessagingPlugin.java    From cordova-plugin-firebase-messaging with MIT License 6 votes vote down vote up
@CordovaMethod
private void getToken(String type, final CallbackContext callbackContext) {
    if (type != null) {
        callbackContext.sendPluginResult(
            new PluginResult(PluginResult.Status.OK, (String)null));
    } else {
        FirebaseInstanceId.getInstance().getInstanceId()
            .addOnCompleteListener(cordova.getActivity(), new OnCompleteListener<InstanceIdResult>() {
                @Override
                public void onComplete(Task<InstanceIdResult> task) {
                    if (task.isSuccessful()) {
                        callbackContext.success(task.getResult().getToken());
                    } else {
                        callbackContext.error(task.getException().getMessage());
                    }
                }
            });
    }
}
 
Example #11
Source File: MainActivity.java    From NaviBee with GNU General Public License v3.0 6 votes vote down vote up
private void logOut() {
    // sign out firebase
    NaviBeeApplication.getInstance().uninit();

    FirebaseAuth.getInstance().signOut();

    // sign out google login
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id))
            .requestEmail()
            .build();
    GoogleSignIn.getClient(this, gso).signOut();

    // reset token to prevent further messages
    try {
        FirebaseInstanceId.getInstance().deleteInstanceId();
    } catch (Exception e) {
        Timber.e(e, "Error occurred while resetting tokens.");
    }


    Intent intent = new Intent(this, LoginActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
    startActivity(intent);
    this.finish();
}
 
Example #12
Source File: AboutFragment.java    From lbry-android with MIT License 6 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    Context context = getContext();
    if (context instanceof MainActivity) {
        MainActivity activity = (MainActivity) context;
        LbryAnalytics.setCurrentScreen(activity, "About", "About");

        if (!Lbry.SDK_READY) {
            activity.addSdkStatusListener(this);
        } else {
            onSdkReady();
        }
    }
    FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
        @Override
        public void onComplete(Task<InstanceIdResult> task) {
            Helper.setViewText(textFirebaseToken, task.isSuccessful() ? task.getResult().getToken() : getString(R.string.unknown));
        }
    });

}
 
Example #13
Source File: SwitchPrivatePublicActivity.java    From kute with Apache License 2.0 6 votes vote down vote up
/**************** Custom Functions Invoked only once on app installation *******/

    public void registerFirebaseDbSelf(final SharedPreferences pref) {
        Person temp = new Person(pref.getString("Name", null), pref.getString("Id", null), pref.getString("Profile_Image", null), FirebaseInstanceId.getInstance().getToken());
        DatabaseReference root = FirebaseDatabase.getInstance().getReference();
        DatabaseReference users = root.child("Users");
        Log.d(TAG, "Saving Self To db");
        users.child(temp.id).setValue(temp).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Log.d(TAG, "Firebase Self Add Error:" + e.toString());
                //reinvert the boolean if saving the user details face an error
                pref.edit().putBoolean("Register_db", true).apply();
            }
        });
    }
 
Example #14
Source File: MyFirebaseInstanceIDService.java    From protrip with MIT License 6 votes vote down vote up
@Override
public void onTokenRefresh() {
    super.onTokenRefresh();
    String refreshedToken = FirebaseInstanceId.getInstance().getToken();

    // Saving reg id to shared preferences
    storeRegIdInPref(refreshedToken);

    // sending reg id to your server
    sendRegistrationToServer(refreshedToken);

    // Notify UI that registration has completed, so the progress indicator can be hidden.
    Intent registrationComplete = new Intent(Constants.REGISTRATION_COMPLETE);
    registrationComplete.putExtra("token", refreshedToken);
    LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}
 
Example #15
Source File: Global.java    From android_sdk_demo_apps with Apache License 2.0 6 votes vote down vote up
private void initFirebase() {
    if (PROJECT_ID.isEmpty() || API_KEY.isEmpty() || FCM_SENDER_ID.isEmpty()) {
        missingCredentials = true;
        return;
    }

    FirebaseOptions options = new FirebaseOptions.Builder()
            .setApplicationId(PROJECT_ID)
            .setApiKey(API_KEY)
            .setGcmSenderId(FCM_SENDER_ID)
            .build();

    FirebaseApp.initializeApp(this, options);

    try {
        String token = FirebaseInstanceId.getInstance().getToken();
        if (token != null) {
            Log.d(LOG_TAG, "Obtained FCM token");
            ZopimChatApi.setPushToken(token);
        }
    } catch (IllegalStateException e) {
        Log.d(LOG_TAG, "Error requesting FCM token");
    }
}
 
Example #16
Source File: QiscusCore.java    From qiscus-sdk-android with Apache License 2.0 6 votes vote down vote up
private static void configureFcmToken() {
    if (hasSetupUser() && getChatConfig().isEnableFcmPushNotification()) {
        String fcmToken = getFcmToken();
        if (fcmToken != null) {
            registerDeviceToken(fcmToken);
        } else {
            Observable.just(null)
                    .doOnNext(o -> {
                        try {
                            FirebaseInstanceId.getInstance().deleteInstanceId();
                        } catch (IOException ignored) {
                            //Do nothing
                        }
                    })
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(aVoid -> {
                    }, throwable -> {
                    });
        }
    }
}
 
Example #17
Source File: LeanplumFcmProvider.java    From Leanplum-Android-SDK with Apache License 2.0 6 votes vote down vote up
@Override
public void getCurrentRegistrationIdAndUpdateBackend() {
  FirebaseInstanceId.getInstance().getInstanceId()
      .addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
        @Override
        public void onComplete(@NonNull Task<InstanceIdResult> task) {
          if (!task.isSuccessful()) {
            Log.e("getInstanceId failed");
            return;
          }
          // Get new Instance ID token
          String tokenId = task.getResult().getToken();
          if (!TextUtils.isEmpty(tokenId)) {
              onRegistrationIdReceived(Leanplum.getContext(), tokenId);
            }
          }
      });
}
 
Example #18
Source File: FCMPlugin.java    From capacitor-fcm with MIT License 6 votes vote down vote up
@PluginMethod()
public void deleteInstance(final PluginCall call) {
    Runnable r = () -> {
        try {
            FirebaseInstanceId.getInstance().deleteInstanceId();
            call.success();
        } catch (IOException e) {
            e.printStackTrace();
            call.error("Cant delete Firebase Instance ID", e);
        }
    };

    // Run in background thread since `deleteInstanceId()` is a blocking request.
    // See https://firebase.google.com/docs/reference/android/com/google/firebase/iid/FirebaseInstanceId#deleteInstanceId()
    new Thread(r).start();
}
 
Example #19
Source File: PushNotificationRegistration.java    From pusher-websocket-android with MIT License 6 votes vote down vote up
/**
 * @deprecated Push Notifications are no longer supported in this SDK.
 *
 * Please use Pusher Beams, our new Push Notifications product: www.pusher.com/beams
 * If you're planning to migrate, check our migration guide:
 * https://pusher.com/docs/push_notifications/migration
 */
@Deprecated
public void registerFCM(Context context, final PushNotificationRegistrationListener listener) throws ManifestValidator.InvalidManifestException {
    manifestValidator.validateFCM(context);

    TokenRegistry tokenRegistry = newTokenRegistry(listener, context, PlatformType.FCM);
    FCMInstanceIDService.setTokenRegistry(tokenRegistry);
    String token = FirebaseInstanceId.getInstance().getToken();

    if (token != null) {
        try {
            tokenRegistry.receive(token);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}
 
Example #20
Source File: FcmUtil.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Retrieves the current FCM token. If one isn't available, it'll be generated.
 */
@WorkerThread
public static Optional<String> getToken() {
  CountDownLatch          latch = new CountDownLatch(1);
  AtomicReference<String> token = new AtomicReference<>(null);

  FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener(task -> {
    if (task.isSuccessful() && task.getResult() != null && !TextUtils.isEmpty(task.getResult().getToken())) {
      token.set(task.getResult().getToken());
    } else {
      Log.w(TAG, "Failed to get the token.", task.getException());
    }

    latch.countDown();
  });

  try {
    latch.await();
  } catch (InterruptedException e) {
    Log.w(TAG, "Was interrupted while waiting for the token.");
  }

  return Optional.fromNullable(token.get());
}
 
Example #21
Source File: FIRMessagingModule.java    From react-native-fcm with MIT License 5 votes vote down vote up
@ReactMethod
public void getEntityFCMToken(Promise promise) {
    try {
        String senderId = FirebaseApp.getInstance().getOptions().getGcmSenderId();
        String token = FirebaseInstanceId.getInstance().getToken(senderId, "FCM");
        Log.d(TAG, "Firebase token: " + token);
        promise.resolve(token);
    } catch (Throwable e) {
        e.printStackTrace();
        promise.reject(null,e.getMessage());
    }
}
 
Example #22
Source File: MyFirebaseInstanceIDService.java    From GcmForMojo with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Called if InstanceID token is updated. This may occur if the security of
 * the previous token had been compromised. Note that this is called when the InstanceID token
 * is initially generated so this is where you would retrieve the token.
 */
// [START refresh_token]
@Override
public void onTokenRefresh() {
    // Get updated InstanceID token.
    deviceGcmToken = FirebaseInstanceId.getInstance().getToken();
    Log.d(TAG, "Refreshed token: " + deviceGcmToken);

    // If you want to send messages to this application instance or
    // manage this apps subscriptions on the server side, send the
    // Instance ID token to your app server.
    sendRegistrationToServer(deviceGcmToken);
}
 
Example #23
Source File: NotifyFirebaseInstanceIDService.java    From video-quickstart-android with MIT License 5 votes vote down vote up
/**
 * Called if InstanceID token is updated. This may occur if the security of
 * the previous token had been compromised. Note that this is called when the InstanceID token
 * is initially generated so this is where you would retrieve the token.
 */
// [START refresh_token]
@Override
public void onTokenRefresh() {
    // Get updated InstanceID token.
    String refreshedToken = FirebaseInstanceId.getInstance().getToken();
    Log.d(TAG, "Refreshed token: " + refreshedToken);

    // If you want to send messages to this application instance or
    // manage this apps subscriptions on the server side, send the
    // Instance ID token to your app server.
    sendRegistrationToServer(refreshedToken);
}
 
Example #24
Source File: FIRMessagingModule.java    From react-native-fcm with MIT License 5 votes vote down vote up
@ReactMethod
public void getFCMToken(Promise promise) {
    try {
        Log.d(TAG, "Firebase token: " + FirebaseInstanceId.getInstance().getToken());
        promise.resolve(FirebaseInstanceId.getInstance().getToken());
    } catch (Throwable e) {
        e.printStackTrace();
        promise.reject(null,e.getMessage());
    }
}
 
Example #25
Source File: ProfileInteractor.java    From CourierApplication with Mozilla Public License 2.0 5 votes vote down vote up
private String checkAndSetCurrentUserToken(String userUid) {
    String instanceId = FirebaseInstanceId.getInstance().getToken();
    if(instanceId != null) {
        DatabaseReference mDatabaseReference = FirebaseDatabase.getInstance().getReference();
        mDatabaseReference.child("users")
                .child(userUid)
                .child("instanceId")
                .setValue(instanceId);
    }
    return instanceId;
}
 
Example #26
Source File: MyFirebaseInstanceIDService.java    From BOMBitUP with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Called if InstanceID token is updated. This may occur if the security of
 * the previous token had been compromised. Note that this is called when the InstanceID token
 * is initially generated so this is where you would retrieve the token.
 */
// [START refresh_token]
@Override
public void onTokenRefresh() {
    // Get updated InstanceID token.
    String refreshedToken = FirebaseInstanceId.getInstance().getToken();
    Log.d(TAG, "Refreshed token: " + refreshedToken);

    // If you want to send messages to this application instance or
    // manage this apps subscriptions on the server side, send the
    // Instance ID token to your app server.
    sendRegistrationToServer(refreshedToken);
}
 
Example #27
Source File: TwilioVoiceModule.java    From react-native-twilio-programmable-voice with MIT License 5 votes vote down vote up
private void registerForCallInvites() {
    FirebaseApp.initializeApp(getReactApplicationContext());
    final String fcmToken = FirebaseInstanceId.getInstance().getToken();
    if (fcmToken != null) {
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "Registering with FCM");
        }
        Voice.register(getReactApplicationContext(), accessToken, Voice.RegistrationChannel.FCM, fcmToken, registrationListener);
    }
}
 
Example #28
Source File: Cache.java    From tindroid with Apache License 2.0 5 votes vote down vote up
public static Tinode getTinode() {
    if (sTinode == null) {
        sTinode = new Tinode("Tindroid/" + TindroidApp.getAppVersion(), API_KEY,
                BaseDb.getInstance().getStore(), null);
        sTinode.setOsString(Build.VERSION.RELEASE);

        // Default types for parsing Public, Private fields of messages
        sTinode.setDefaultTypeOfMetaPacket(VxCard.class, PrivateType.class);
        sTinode.setMeTypeOfMetaPacket(VxCard.class);
        sTinode.setFndTypeOfMetaPacket(VxCard.class);

        // Set device language
        sTinode.setLanguage(Locale.getDefault().toString());

        // Keep in app to prevent garbage collection.
        TindroidApp.retainTinodeCache(sTinode);
    }

    FirebaseInstanceId fbId = FirebaseInstanceId.getInstance();
    //noinspection ConstantConditions: Google lies about getInstance not returning null.
    if (fbId != null) {
        fbId.getInstanceId()
            .addOnSuccessListener(new OnSuccessListener<InstanceIdResult>() {
                @Override
                public void onSuccess(InstanceIdResult instanceIdResult) {
                    if (sTinode != null) {
                        sTinode.setDeviceToken(instanceIdResult.getToken());
                    }
                }
            });
    }
    return sTinode;
}
 
Example #29
Source File: ProfileEditInteractor.java    From CourierApplication with Mozilla Public License 2.0 5 votes vote down vote up
private String checkAndSetCurrentUserToken(String userUid) {
    String instanceId = FirebaseInstanceId.getInstance().getToken();
    if(instanceId != null) {
        DatabaseReference mDatabaseReference = FirebaseDatabase.getInstance().getReference();
        mDatabaseReference.child("users")
                .child(userUid)
                .child("instanceId")
                .setValue(instanceId);
    }
    return instanceId;
}
 
Example #30
Source File: MainActivity.java    From quickstart-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  final ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());
  setContentView(binding.getRoot());

  mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
  mInAppMessaging = FirebaseInAppMessaging.getInstance();

  mInAppMessaging.setAutomaticDataCollectionEnabled(true);
  mInAppMessaging.setMessagesSuppressed(false);

  binding.eventTriggerButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              mFirebaseAnalytics.logEvent("engagement_party", new Bundle());
              Snackbar.make(view, "'engagement_party' event triggered!", Snackbar.LENGTH_LONG)
                  .setAction("Action", null)
                  .show();
            }
          });

  // Get and display/log the Instance ID
  FirebaseInstanceId.getInstance().getInstanceId()
          .addOnSuccessListener(new OnSuccessListener<InstanceIdResult>() {
            @Override
            public void onSuccess(InstanceIdResult instanceIdResult) {
              String instanceId = instanceIdResult.getId();
              binding.instanceIdText.setText(getString(R.string.instance_id_fmt, instanceId));
              Log.d(TAG, "InstanceId: " + instanceId);
            }
          });
}