当我从Firebase Cloud Messaging Console单击通知时,我想启动Chrome自定义选项卡。我发送了一个通知,键为“ url”,值为“ https://www.bbc.com/”。
但是我单击通知,打开“主要活动”。
public class MyFirebaseMessagingService extends FirebaseMessagingService {
public void onMessageReceived(RemoteMessage remoteMessage) {
CCT(remoteMessage.getData().get("url"));
}
public void CCT (String url) { ///Chrome installed
CustomTabsIntent.Builder builder=new CustomTabsIntent.Builder();
CustomTabsIntent intent = builder.build();
builder.setShowTitle(true);
builder.setToolbarColor(getResources().getColor(R.color.titlebarcolor));
builder.addDefaultShareMenuItem();
CustomTabsIntent intentCustomTabs = builder.build();
intentCustomTabs.intent.setPackage("com.android.chrome");
intent.launchUrl(this, Uri.parse(url));
}
}