OneSignal |从通知有效负载获取URL并在自定义WebView中打开

时间:2016-10-25 06:02:15

标签: android google-cloud-messaging android-webview

OneSignal默认提供在浏览器中打开URL的功能。我想发送一个带有通知的网址,该网址会在我创建的reactContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit("EVENT_TAG", "PASS YOUR OBJECT"); 中打开网址。我已经分享了收到通知的地方的一个片段:

WebView

我不确定如何在正在打开的推送中检索网址并在 class ExampleNotificationReceivedHandler implements OneSignal.NotificationReceivedHandler { @Override public void notificationReceived(OSNotification notification) { JSONObject data = notification.payload.additionalData; String customKey; if (data != null) { customKey = data.optString("customkey", null); if (customKey != null) Log.i("OneSignalExample", "customkey set with value: " + customKey); } } } 中将其打开。

2 个答案:

答案 0 :(得分:3)

SlashG的回答帮助了我。这是我的实现......我在我的Application类Option Explicit Sub Test() Dim olApp As Outlook.Application Dim olNs As Namespace Dim Fldr As MAPIFolder Dim olMail As Object Dim i As Integer, j As Integer Set olApp = New Outlook.Application Set olNs = olApp.GetNamespace("MAPI") Set Fldr = olNs.GetDefaultFolder(olFolderSentMail) i = 1 For Each olMail In Fldr.Items ' check if mail subject contains "Task Completed" in the email title If olMail.Subject Like "*Task Completed*" Then 'Range("A" & i).Value = olMail.Subject ' <-- output email name to column A 'Range("B" & i).Value = olMail.SentOn ' <-- output email sent date to column B olMail.Display ' show email through Excel i = i + 1 End If Next olMail End Sub

中添加了这段代码
onCreate()

答案 1 :(得分:2)

如果您在其他数据中包含该网址,OneSignal将无法使用该网址。您可以根据需要使用其他数据。当您致电OneSignal.NotificationOpenedHandler时,您需要实施OneSignal.startInit(context)并将其设置为您的OneSignal实例。

此界面在您的通知开启时有一个回调notificationOpened()。此方法的参数类型为OSNotificationOpenResult。您可以检索notification&gt; payload&gt; additionalData。从此处launch_url获取additionalData,然后使用WebView与其联系。

如果您需要进一步的帮助,请与我们联系。