Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,40 @@ public Result doWork() {
return Result.success();
}
}

private void registerFid() {
// [START register_fid]
// Trigger manual registration if auto-initialization is turned off.
// Consider calling this every time the app starts to guarantee sync status.
FirebaseMessaging.getInstance().register()
.addOnCompleteListener(task -> {
if (!task.isSuccessful()) {
// Registration failed. Consider retrying the registration with exponential backoff.
Log.w(TAG, "Failed to register with Firebase Cloud Messaging", task.getException());
}
// Success! The Firebase Installation ID can be used to target messages to this app
// instance and will be delivered asynchronously to your onRegistered() callback.
});
// [END register_fid]
}

// [START on_fid_registered]
/**
* There are three scenarios when `onRegistered` is called:
* 1) Every time a manual `register()` call finishes successfully
* 2) Whenever the FID is changed and the app is re-registered with FCM via the new FID
* 3) Automatically on app startup or routine sync when auto-initialization is enabled.
Comment thread
s-chandels marked this conversation as resolved.
Outdated
Comment thread
s-chandels marked this conversation as resolved.
Outdated
* Under #2, there are three scenarios when the existing FID is changed:
* A) App is restored to a new device
* B) User uninstalls/reinstalls the app
* C) User clears app data
*/
@Override
public void onRegistered(@NonNull String installationId) {
Log.d(TAG, "Registered installation ID: " + installationId);

// Send the Firebase Installation ID to your app server.
sendRegistrationToServer(installationId);
}
// [END on_fid_registered]
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,38 @@ class MyFirebaseMessagingService : FirebaseMessagingService() {
return Result.success()
}
}

private fun registerFid() {
Comment thread
s-chandels marked this conversation as resolved.
Outdated
// [START register_fid]
// Trigger manual registration if auto-initialization is turned off.
// Consider calling this every time the app starts to guarantee sync status.
FirebaseMessaging.getInstance().register()
.addOnCompleteListener { task ->
if (!task.isSuccessful()) {
Log.w(TAG, "Failed to register with Firebase Cloud Messaging", task.exception)
}
// Success! The Firebase Installation ID can be used to target messages to this app
// instance and will be delivered asynchronously to your onRegistered() callback.
}
}
// [END register_fid]
Comment thread
s-chandels marked this conversation as resolved.
Outdated

// [START on_fid_registered]
/**
* There are three scenarios when `onRegistered` is called:
* 1) Every time a manual `register()` call finishes successfully
* 2) Whenever the FID is changed and the app is re-registered with FCM via the new FID.
* 3) Automatically on app startup or routine sync when auto-initialization is enabled.
Comment thread
s-chandels marked this conversation as resolved.
Outdated
* Under #2, there are three scenarios when the existing FID is changed:
* A) App is restored to a new device
* B) User uninstalls/reinstalls the app
* C) User clears app data
*/
override fun onRegistered(installationId: String) {
Log.d(TAG, "Registered installation ID: $installationId")

// Send the Firebase Installation ID to your app server.
sendRegistrationToServer(installationId)
}
// [END on_fid_registered]
}
Loading