Шаблон, который я использовал: https://github.com/mgks/Android-SmartWebView
На самом деле, шаблон не имеет функции fcm. Я добавил это вручную. Я упоминал здесь, чтобы вы посмотрели в файл mainacctivity.
Я хочу открыть определенную ссылку, когда пользователь щелкает мое уведомление.
Мой строитель уведомлений:
// pending implicit intent to view url
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("LINK",link);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, ADMIN_CHANNEL_ID)
.setLargeIcon(BitmapFactory.decodeResource(getBaseContext().getResources(), R.mipmap.ic_launcher)) //set it in the notification
.setSmallIcon(R.mipmap.ic_launcher) //a resource for your custom small icon
.setContentTitle(title) //the "title" value you sent in your notification
.setContentText(message) //ditto
.setContentIntent(pendingIntent)
.setAutoCancel(true) //dismisses the notification on click
.setSound(defaultSoundUri)
.setStyle(new NotificationCompat.BigPictureStyle()
.setSummaryText(message)
.bigPicture(bitmap)
.setBigContentTitle(title));
Я попробовал это в MainActivity:
Intent intent = getIntent();
if (getIntent().getExtras() != null && getIntent().getExtras().getString("link", null) != null && !getIntent().getExtras().getString("link", null).equals("")) {
String url = null;
if (getIntent().getExtras().getString("link").contains("http")) {
url = getIntent().getExtras().getString("link");
} else {
url = "http://" + getIntent().getExtras().getString("link");
}
aswm_view(url, false);
} else {
//Rendering the default URL
aswm_view(ASWV_URL, false);
}
(near lines 250)
Но, ничего не работает. Может кто-нибудь, пожалуйста, помогите мне?
Thankyou.