通知在浏览器中打开,我想打开webview。 如何在WebView中打开OneSignal通知,谢谢
以下是MainActivity中的代码
.java class
或OneSignal.startInit(this).setNotificationOpenedHandler(new OneSignal.NotificationOpenedHandler() {
@Override
public void notificationOpened(OSNotificationOpenResult result) {
String launchURL = result.notification.payload.launchURL;
if (launchURL != null) {
// Log.d(Const.DEBUG, "Launch URL: " + launchURL);
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("url", launchURL);
startActivity(intent);
} else {
// Log.d(Const.DEBUG, "Launch URL not found");
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
}).init();