Я делаю мобильное приложение с веб-просмотром (для Android и IOS). Я строю это с Кордовой. Я отправляю уведомления pu sh с помощью OneSignal + Firebase, это работает правильно.
Я отправляю URL-адрес (указывающий на мой сайт) с уведомлением pu sh. Я установил плагин cordova-deeplinking. Когда я нажимаю уведомление pu sh, телефон правильно открывает URL моего сайта в приложении.
Моя проблема: я попытался отправить какой-то путь, например: https://example.org/path-to-news, но приложение всегда открывает пример главной страницы: https://example.org. Приложение не может перенаправить URL-адрес в приложении веб-просмотра. Какое решение моей проблемы?
конфигурация xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example" android-versionCode="10101" version="01.01.01" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>example</name>
<description>example mobile</description>
<author email="example@gmail.com" href="https://example.com">ExampleLLC</author>
<content src="https://example.com/" />
<allow-navigation href="https://example.com//*" />
<access origin="*" />
<access origin="cdvfile://*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-intent href="rtsp://*" />
<allow-intent href="rtmp://*" />
<allow-intent href="rtp://*" />
<allow-intent href="udp://*" />
<allow-intent href="file://*" />
<allow-intent href="mms:*" />
<allow-intent href="google.navigation:*" />
<allow-intent href="google.streetview:*" />
<allow-intent href="maps:*" />
<allow-intent href="map:*" />
<allow-intent href="googlemap:*" />
<allow-intent href="whatsapp:*" />
<allow-intent href="line:*" />
<allow-intent href="twitter:*" />
<allow-intent href="fb:*" />
<allow-intent href="fbapi20130214:*" />
<allow-intent href="skype:*" />
<allow-intent href="linkedin:*" />
<allow-intent href="googlegmail:*" />
<allow-intent href="youtube:*" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data://*" />
<allow-navigation href="file://*" />
<allow-navigation href="http://localhost:8080/*" />
<preference name="AndroidLaunchMode" value="singleInstance" />
<preference name="AppendUserAgent" value="example" />
<preference name="ScrollEnabled" value="false" />
<preference name="android-minSdkVersion" value="19" />
<preference name="android-targetSdkVersion" value="28" />
<preference name="BackupWebStorage" value="none" />
<!-- cordova-plugin-splashscreen -->
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="FadeSplashScreenDuration" value="300" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" />
<preference name="ShowSplashScreenSpinner" value="true"/>
<preference name="SplashScreenSpinnerColor" value="white"/>
<!-- ./cordova-plugin-splashscreen -->
<!-- cordova-plugin-statusbar -->
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarStyle" value="lightcontent" />
<preference name="StatusBarBackgroundColor" value="#a60009" />
<!-- ./cordova-plugin-statusbar -->
<universal-links>
<host name="example.com" scheme="https">
<path url="*" />
</host>
</universal-links>
<platform name="android">
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
<allow-intent href="market:*" />
<preference name="loadUrlTimeoutValue" value="20000" />
<preference name="ErrorUrl" value="file:///android_asset/www/retry.html" />
<icon density="ldpi" src="www/resources/android/icon/drawable-ldpi-icon.png" />
<icon density="mdpi" src="www/resources/android/icon/drawable-mdpi-icon.png" />
<icon density="hdpi" src="www/resources/android/icon/drawable-hdpi-icon.png" />
<icon density="xhdpi" src="www/resources/android/icon/drawable-xhdpi-icon.png" />
<icon density="xxhdpi" src="www/resources/android/icon/drawable-xxhdpi-icon.png" />
<icon density="xxxhdpi" src="www/resources/android/icon/drawable-xxxhdpi-icon.png" />
<splash density="land-ldpi" src="www/resources/android/splash/drawable-land-ldpi-screen.png" />
<splash density="land-mdpi" src="www/resources/android/splash/drawable-land-mdpi-screen.png" />
<splash density="land-hdpi" src="www/resources/android/splash/drawable-land-hdpi-screen.png" />
<splash density="land-xhdpi" src="www/resources/android/splash/drawable-land-xhdpi-screen.png" />
<splash density="land-xxhdpi" src="www/resources/android/splash/drawable-land-xxhdpi-screen.png" />
<splash density="land-xxxhdpi" src="www/resources/android/splash/drawable-land-xxxhdpi-screen.png" />
<splash density="port-ldpi" src="www/resources/android/splash/drawable-port-ldpi-screen.png" />
<splash density="port-mdpi" src="www/resources/android/splash/drawable-port-mdpi-screen.png" />
<splash density="port-hdpi" src="www/resources/android/splash/drawable-port-hdpi-screen.png" />
<splash density="port-xhdpi" src="www/resources/android/splash/drawable-port-xhdpi-screen.png" />
<splash density="port-xxhdpi" src="www/resources/android/splash/drawable-port-xxhdpi-screen.png" />
<splash density="port-xxxhdpi" src="www/resources/android/splash/drawable-port-xxxhdpi-screen.png" />
</platform>
<!--
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<icon height="57" src="www/resources/ios/icon/icon.png" width="57" />
<icon height="114" src="www/resources/ios/icon/icon@2x.png" width="114" />
<icon height="40" src="www/resources/ios/icon/icon-40.png" width="40" />
<icon height="80" src="www/resources/ios/icon/icon-40@2x.png" width="80" />
<icon height="120" src="www/resources/ios/icon/icon-40@3x.png" width="120" />
<icon height="50" src="www/resources/ios/icon/icon-50.png" width="50" />
<icon height="100" src="www/resources/ios/icon/icon-50@2x.png" width="100" />
<icon height="60" src="www/resources/ios/icon/icon-60.png" width="60" />
<icon height="120" src="www/resources/ios/icon/icon-60@2x.png" width="120" />
<icon height="180" src="www/resources/ios/icon/icon-60@3x.png" width="180" />
<icon height="72" src="www/resources/ios/icon/icon-72.png" width="72" />
<icon height="144" src="www/resources/ios/icon/icon-72@2x.png" width="144" />
<icon height="76" src="www/resources/ios/icon/icon-76.png" width="76" />
<icon height="152" src="www/resources/ios/icon/icon-76@2x.png" width="152" />
<icon height="167" src="www/resources/ios/icon/icon-83.5@2x.png" width="167" />
<icon height="29" src="www/resources/ios/icon/icon-small.png" width="29" />
<icon height="58" src="www/resources/ios/icon/icon-small@2x.png" width="58" />
<icon height="87" src="www/resources/ios/icon/icon-small@3x.png" width="87" />
<icon height="1024" src="www/resources/ios/icon/icon-1024.png" width="1024" />
<splash height="1136" src="www/resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
<splash height="1334" src="www/resources/ios/splash/Default-667h.png" width="750" />
<splash height="2208" src="www/resources/ios/splash/Default-736h.png" width="1242" />
<splash height="1242" src="www/resources/ios/splash/Default-Landscape-736h.png" width="2208" />
<splash height="1536" src="www/resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
<splash height="2048" src="www/resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
<splash height="768" src="www/resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
<splash height="2048" src="www/resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
<splash height="2732" src="www/resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
<splash height="1024" src="www/resources/ios/splash/Default-Portrait~ipad.png" width="768" />
<splash height="960" src="www/resources/ios/splash/Default@2x~iphone.png" width="640" />
<splash height="480" src="www/resources/ios/splash/Default~iphone.png" width="320" />
<splash height="2732" src="www/resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
</platform>
-->
<preference name="CRIInjectFirstFiles" value="www/init.js" />
<plugin name="cordova-plugin-whitelist" />
<plugin name="cordova-plugin-inappbrowser" />
<plugin name="cordova-plugin-ionic-webview" />
<plugin name="cordova-plugin-ionic-keyboard" />
<plugin name="cordova-plugin-statusbar" />
<plugin name="cordova-plugin-splashscreen" />
<plugin name="cordova-plugin-inappbrowser" />
<plugin name="cordova-plugin-remote-injection" />
<plugin name="onesignal-cordova-plugin" />
<preference name="phonegap-version" value="cli-9.0.0" />
</widget>
инициализация js
var app = {
initialize: function() {
document.addEventListener("deviceready", this.onDeviceReady.bind(this), false);
},
onDeviceReady: function() {
document.onclick = function(e) {
e = e || window.event;
var element = e.target || e.srcElement;
if (element.target == "_blank") {
window.open(element.href, "_blank", "location=yes");
return false;
}
if (element.target == "_system") {
window.open(element.href, "_system", "location=yes");
return false;
}
if (element.target == "_self") {
window.open(element.href, "_self");
return false;
}
};
// onesignal
if(window.plugins && window.plugins.OneSignal){
window.plugins.OneSignal.enableNotificationsWhenActive(true);
var notificationOpenedCallback = function(jsonData){};
window.plugins.OneSignal.startInit("xxx","xxx").handleNotificationOpened(notificationOpenedCallback).endInit();
}
},
};
app.initialize();
индекс . html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no"/>
<meta http-equiv="Refresh" content="0; url=https://example.com/" />
<title>example</title>
</head>
<body>
<p><a href="https://example.com/">Enter</a></p>
</body>
</html>