当我的应用程序在前台,然后通知url链接自动打开,无需用户的任何贡献。当应用程序在前台通知包含自动打开
现在,我想在通知栏中保留通知,并且当用户按下将打开url链接的通知时。 还有一件事我不得不提,当我的应用程序在后台工作正常。通知到达通知栏。 我想要为前景做同样的事情。
请帮忙, 在此先感谢。
我FirebaseMessagingServices
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = "MyFirebaseMsgService";
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
if(remoteMessage.getData().size()>0){
String url = remoteMessage.getData().get("url");
Intent intent = new Intent("com.bellecarib_FCM-MESSAGE");
intent.putExtra("url",url);
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(this);
localBroadcastManager.sendBroadcast(intent);
}
}
这里是我的MainActivity代码
LocalBroadcastManager.getInstance(this).registerReceiver(mHandler, new IntentFilter("com.bellecarib_FCM-MESSAGE"));
if(getIntent().getExtras() != null){
for(String key: getIntent().getExtras().keySet()){
if(key.equals(("url"))){
mwebView.loadUrl(getIntent().getExtras().getString(key));
Toast.makeText(getApplicationContext(),"Opening The Notification Page",Toast.LENGTH_LONG).show();
}
}
}
首先,从您粘贴不能看到你扔一个通知代码。改述你的问题。当你收到消息时你想要发出通知吗? – Dibzmania
我收到前台和后台的应用程序通知。 –
但是当我的应用程序在前台通知包含直接打开没有它在通知栏中处理。我想保持在通知栏中的通知,然后当用户按通知时,它会打开,如同它在后台应用程序打开。谢谢 –