如何从我的 WebView react-native 应用程序中的 One Signal 推送通知打开 https URL?
How do I open https URL from One Signal push-notification WITHIN my WebView react-native app?
我使用 WebView 和我公司网站的初始 URL 创建了一个 React-native 应用程序(在 android 中测试)。
我希望用户在单击 OneSignal 推送通知时能够重定向到特定网站的产品页面(例如 https://www.test.com/product/hoodie-with-zipper/),发送的通知中包含预期启动 URL。问题是,我希望用户使用我的 WebView 应用程序而不是浏览器打开 URL。
到目前为止我已经实现和测试的功能:
已实施和测试 WebView(目前没有问题)
在本地实施和测试深层链接(使用 'myapp://' 的 android 方案,目前没有问题)
为 react-native 及其 firebase 要求实现了 OneSignal 推送通知 SDK(目前没有问题)
正如我之前在第 2 点中提到的,我已经尝试并成功地使用 'myapp://' 的 android 方案实现了深度链接。但是,当我尝试实施 'https://' 的 android 方案时,OneSignal 推送通知的启动 URL 是用浏览器打开的,而不是我的 WebView 应用程序。
I want the user to be able to get redirected to a spesific website's product page (for example https://www.test.com/product/hoodie-with-zipper/) WHEN they clicked the OneSignal push notification with the intended launch URL included in the sent notification, but it'll be opened with React-native WebView instead of browser.
^ 那么,我应该怎么做才能做到这一点?
提前致谢。
您应该通过 additional data in the notification. Then, in your app you should open a webview to the specified url.The Launch URL feature on the dashboard or the url field on the REST API automatically opens the web browser on the mobile device when the notification is tapped on. If you would like to open the URL inside your app instead of the browser, you need to send your notification with custom data that can read by your app's SDK. If you're using our dashboard to send notifications, the sending notification options allows you to include additional data to be sent with your notification. If you're using our API to send notifications, you can set the 'data' field to a JSON object hash of extra custom data. For example, you could set targetUrl
for the key and https://google.com 传入 URL 作为值来自行处理。然后在您的应用代码中,从 NotificationOpened 回调中的 additionalData 读取 targetUrl 值(名称取决于所使用的 OneSignal SDK)。
我使用 WebView 和我公司网站的初始 URL 创建了一个 React-native 应用程序(在 android 中测试)。 我希望用户在单击 OneSignal 推送通知时能够重定向到特定网站的产品页面(例如 https://www.test.com/product/hoodie-with-zipper/),发送的通知中包含预期启动 URL。问题是,我希望用户使用我的 WebView 应用程序而不是浏览器打开 URL。
到目前为止我已经实现和测试的功能:
已实施和测试 WebView(目前没有问题)
在本地实施和测试深层链接(使用 'myapp://' 的 android 方案,目前没有问题)
为 react-native 及其 firebase 要求实现了 OneSignal 推送通知 SDK(目前没有问题)
正如我之前在第 2 点中提到的,我已经尝试并成功地使用 'myapp://' 的 android 方案实现了深度链接。但是,当我尝试实施 'https://' 的 android 方案时,OneSignal 推送通知的启动 URL 是用浏览器打开的,而不是我的 WebView 应用程序。
I want the user to be able to get redirected to a spesific website's product page (for example https://www.test.com/product/hoodie-with-zipper/) WHEN they clicked the OneSignal push notification with the intended launch URL included in the sent notification, but it'll be opened with React-native WebView instead of browser.
^ 那么,我应该怎么做才能做到这一点? 提前致谢。
您应该通过 additional data in the notification. Then, in your app you should open a webview to the specified url.The Launch URL feature on the dashboard or the url field on the REST API automatically opens the web browser on the mobile device when the notification is tapped on. If you would like to open the URL inside your app instead of the browser, you need to send your notification with custom data that can read by your app's SDK. If you're using our dashboard to send notifications, the sending notification options allows you to include additional data to be sent with your notification. If you're using our API to send notifications, you can set the 'data' field to a JSON object hash of extra custom data. For example, you could set targetUrl
for the key and https://google.com 传入 URL 作为值来自行处理。然后在您的应用代码中,从 NotificationOpened 回调中的 additionalData 读取 targetUrl 值(名称取决于所使用的 OneSignal SDK)。