Using Firebase I am trying to send notification in a 'key' with a 'value' URL link. I got the notification every time, but the problem is which URL link I send in my value that wouldn't open in my webview.
Here I've attached my webview activity
public class WebViewActivity extends AppCompatActivity {
private WebView notiWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
notiWebView = (WebView) findViewById(R.id.NotiWebView);
if(getIntent().getExtras() != null){
for(String key: getIntent().getExtras().keySet()){
if(key.equals(("url"))){
notiWebView.loadUrl(key);
}
}
}
}
here is my FirebaseInstanceIdService
public class MyFirebaseInstanceIdService extends FirebaseInstanceIdService {
@Override
public void onTokenRefresh(){
String token = FirebaseInstanceId.getInstance().getToken();
Log.d("TOKEN",token);
}
and here is FirebaseInstanceMessagingService
public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Intent intent = new Intent(this,WebViewActivity.class);
intent.setFlags(intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
notificationBuilder.setContentTitle("My Notification:");
notificationBuilder.setContentText(remoteMessage.getNotification().getBody());
notificationBuilder.setAutoCancel(true);
notificationBuilder.setSmallIcon(R.mipmap.ic_launcher);
notificationBuilder.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
}
Any help will be appreciated. Thanks in advance!