I've followed this method to send my fcm token in the URL.
Following is my custom launcher activity
public class LauncherActivity
extends com.google.androidbrowserhelper.trusted.LauncherActivity {
private String fcmToken;
@Override
protected Uri getLaunchingUrl() {
Uri uri = super.getLaunchingUrl();
return uri
.buildUpon()
.appendQueryParameter("fcmToken", fcmToken)
.build();
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FirebaseMessaging.getInstance().getToken()
.addOnCompleteListener(new OnCompleteListener<String>() {
@Override
public void onComplete(@NonNull Task<String> task) {
if (!task.isSuccessful()) {
return;
}
fcmToken = task.getResult();
launchTwa();
}
});
}
@Override
protected boolean shouldLaunchImmediately() {
return false;
}
Problem is when i run the app for the first time it get stuck in the splash screen.Then after killing the app , second time onward it works.
This issues is discussed in here as well , but with no luck.Any help will be appreciated.
Since i didn't find and resolution to this , following is the way i found to overcome this issue.Now i don't have the stuck in initial step and already token is passed to my server.
LauncherActivity.java
CustomFirebaseMessagingService.java
What is happening is when you first launch the app,
Hope this will help to someone.