如何在WebView中打开OneSignal通知?

时间:2017-06-11 19:16:48

标签: android android-studio onesignal

通知在浏览器中打开,我想打开webview。如何在WebView中打开OneSignal通知,谢谢

以下是MainActivity中的代码

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();

1 个答案:

答案 0 :(得分:0)

不是将URL传递给MainActivity,而只是使用webview创建一个新活动并在那里传递URL。