2017-06-11 20 views
0

ブラウザで通知が開き、webviewを開きます。私はWebViewの中の通知、感謝WebViewでOneSignal通知を開くにはどうすればよいですか?

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

答えて

0

だけではなくWebViewを持つ新しいアクティビティを作成し、そこにURLを渡すMainActivityにURLを渡すコードです。

+0

どうすればできますか? –

+0

新しいアクティビティを作成し、これをお読みください https://www.tutorialspoint.com/android/android_webview_layout.htm –

関連する問題