我创建了一个简单的Web视图来接收来自OneSignal的通知,我使用以下方式发送通知
'data' => array ("launchURL" => $link),
但是我不确定如何处理此数据中发送的链接
如何直接在webview的URL中打开通过onesignal发送的$ link?
public class ApplicationClass extends Application {
@Override
public void onCreate() {
super.onCreate();
OneSignal.startInit(this)
.setNotificationOpenedHandler(new ExampleNotificationOpenedHandler())
.unsubscribeWhenNotificationsAreDisabled(true)
.init();
}
}
class ExampleNotificationOpenedHandler implements OneSignal.NotificationOpenedHandler {
// This fires when a notification is opened by tapping on it and
// puts the launchURL additional data into a string for use in the main activity
public static String launchURL;
@Override
public void notificationOpened(OSNotificationOpenResult result) {
OSNotificationAction.ActionType actionType = result.action.type;
JSONObject data = result.notification.payload.additionalData;
if (data != null) {
launchURL = data.optString("launchURL", null);
}
}
}