我使用phonegap构建,我在Android上的推送通知有问题。当我打开推送通知时,webview重新启动。
启动应用程序时的Logcat
I/CordovaLog(19411): Changing log level to DEBUG(3)
I/CordovaActivity(19411): Apache Cordova native platform version 6.1.2
is starting D/CordovaActivity(19411): CordovaActivity.onCreate()
D/SystemWebViewEngine(19411): CordovaWebView is running on device made
by: motorola D/CordovaWebViewImpl(19411): >>>
loadUrl(file:///android_asset/www/index.html)
D/CordovaActivity(19411): Started the activity.
D/CordovaActivity(19411): Resumed the activity.
D/CordovaWebViewImpl(19411):
onPageDidNavigate(file:///android_asset/www/index.html)
D/CordovaWebViewImpl(19411):
onPageFinished(file:///android_asset/www/index.html)
D/CordovaNetworkManager(19411): toLower : mobile
D/CordovaNetworkManager(19411): wifi : wifi
D/CordovaNetworkManager(19411): Connection Type: 3g
D/CordovaNetworkManager(19411): Connection Extra Info: internet.movil
D/CordovaNetworkManager(19411): toLower : mobile
D/CordovaNetworkManager(19411): wifi : wifi
D/CordovaNetworkManager(19411): Connection Type: 3g
D/CordovaNetworkManager(19411): Connection Extra Info: internet.movil
W/PluginManager(19411): THREAD WARNING: exec() call to
OneSignalPush.init blocked the main thread for 67ms. Plugin should use
CordovaInterface.getThreadPool().
当我打开通知时
D/CordovaActivity(20982): Paused the activity.
D/CordovaActivity(20982): Stopped the activity.
D/CordovaActivity(20982): CordovaActivity.onDestroy()
D/CordovaWebViewImpl(20982): >>> loadUrl(about:blank)
D/CordovaActivity(20982): CordovaActivity.onDestroy()
D/CordovaWebViewImpl(20982): >>> loadUrl(about:blank)
D/CordovaActivity(20982): CordovaActivity.onDestroy()
D/CordovaWebViewImpl(20982): >>> loadUrl(about:blank)
I/CordovaLog(22084): Changing log level to DEBUG(3)
I/CordovaActivity(22084): Apache Cordova native platform version 6.1.2
is starting D/CordovaActivity(22084): CordovaActivity.onCreate()
D/SystemWebViewEngine(22084): CordovaWebView is running on device made
by: motorola D/CordovaWebViewImpl(22084): >>>
loadUrl(file:///android_asset/www/index.html)
D/CordovaActivity(22084): Started the activity.
D/CordovaActivity(22084): Resumed the activity.
D/CordovaWebViewImpl(22084):
onPageDidNavigate(file:///android_asset/www/index.html)
D/CordovaWebViewImpl(22084):
onPageFinished(file:///android_asset/www/index.html)
D/CordovaNetworkManager(22084): toLower : mobile
D/CordovaNetworkManager(22084): wifi : wifi
D/CordovaNetworkManager(22084): Connection Type: 4g
D/CordovaNetworkManager(22084): Connection Extra Info: internet.movil
D/CordovaNetworkManager(22084): toLower : mobile
D/CordovaNetworkManager(22084): wifi : wifi
D/CordovaNetworkManager(22084): Connection Type: 4g
D/CordovaNetworkManager(22084): Connection Extra Info: internet.movil
W/PluginManager(22084): THREAD WARNING: exec() call to
OneSignalPush.init blocked the main thread for 99ms. Plugin should use
CordovaInterface.getThreadPool().
已尝试使用以下首选项但仍无法正常工作。
<preference name="AndroidLaunchMode" value="singleTop" />
或者
<preference name="AndroidLaunchMode" value="singleInstance" />
我的config.xml
AccessIn Administracióndebarrios privados AccessIn Team
<gap:config-file platform="ios" parent="NSPhotoLibraryUsageDescription" overwrite="true">
<string>We are using your photos and camera for profile photos.</string>
</gap:config-file>
<!-- Recommend the newest cli but requires cli-5.1.1+ and gradle for Android. -->
<!-- If the below settings are not compatible with your project set the "PGB ANT" version above. -->
<preference name="phonegap-version" value="cli-6.4.0" />
<preference name="android-build-tool" value="gradle" />
<gap:plugin name="onesignal-cordova-plugin" source="npm" spec="^2.0.10" />
<plugin name="cordova-plugin-camera" source="npm" spec="~2.2.0" />
<plugin name="cordova-plugin-media-capture" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-console" source="npm" spec="~1.0.2" />
<plugin name="cordova-plugin-device" source="npm" spec="~1.1.1" />
<plugin name="cordova-plugin-device-orientation" source="npm" spec="~1.0.2" />
<plugin name="cordova-plugin-dialogs" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-file" source="npm" spec="~4.1.1" />
<plugin name="cordova-plugin-file-opener2" source="npm" spec="~2.0.1" />
<plugin name="cordova-plugin-file-transfer" source="npm" spec="~1.5.0" />
<plugin name="cordova-plugin-geolocation" source="npm" spec="~2.1.0" />
<plugin name="cordova-plugin-globalization" source="npm" spec="~1.0.3" />
<plugin name="cordova-plugin-inappbrowser" source="npm" spec="~1.3.0" />
<plugin name="cordova-plugin-media" source="npm" spec="~2.2.0" />
<plugin name="cordova-plugin-network-information" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-splashscreen" source="npm" spec="~4.0.0" />
<plugin name="cordova-plugin-statusbar" source="npm" spec="~2.1.2" />
<plugin name="cordova-plugin-vibration" source="npm" spec="~2.1.0" />
<plugin name="cordova-plugin-whitelist" source="npm" spec="~1.2.1" />
<icon src="icon.png" />
<splash src="splash.png" />
<platform name="android">
<icon platform="android" qualifier="ldpi" src="res/icons/android/icon-36-ldpi.png"/>
<icon platform="android" qualifier="mdpi" src="res/icons/android/icon-48-mdpi.png"/>
<icon platform="android" qualifier="hdpi" src="res/icons/android/icon-72-hdpi.png"/>
<icon platform="android" qualifier="xhdpi" src="res/icons/android/icon-96-xhdpi.png"/>
<icon platform="android" qualifier="xxhdpi" src="res/icons/android/icon-144-xxhdpi.png"/>
<icon platform="android" qualifier="xxxhdpi" src="res/icons/android/icon-192-xxxhdpi.png"/>
<splash platform="android" density="port-ldpi" src="res/screens/android/screen-ldpi-portrait.png" />
<splash platform="android" density="port-mdpi" src="res/screens/android/screen-mdpi-portrait.png" />
<splash platform="android" density="port-hdpi" src="res/screens/android/screen-hdpi-portrait.png" />
<splash platform="android" density="port-xhdpi" src="res/screens/android/screen-xhdpi-portrait.png" />
<splash platform="android" density="land-ldpi" src="res/screens/android/screen-ldpi-landscape.png" />
<splash platform="android" density="land-mdpi" src="res/screens/android/screen-mdpi-landscape.png" />
<splash platform="android" density="land-hdpi" src="res/screens/android/screen-hdpi-landscape.png" />
<splash platform="android" density="land-xhdpi" src="res/screens/android/screen-xhdpi-landscape.png" />
<splash platform="android" qualifier="ldpi" src="res/screens/android/screen-ldpi-portrait.png" />
<splash platform="android" qualifier="mdpi" src="res/screens/android/screen-mdpi-portrait.png" />
<splash platform="android" qualifier="hdpi" src="res/screens/android/screen-hdpi-portrait.png" />
<splash platform="android" qualifier="xhdpi" src="res/screens/android/screen-xhdpi-portrait.png" />
</platform>
<platform name="ios">
<icon platform="ios" src="res/icons/ios/icon-small.png" width="29" height="29" />
<icon platform="ios" src="res/icons/ios/icon-small-2x.png" width="58" height="58" />
<icon platform="ios" src="res/icons/ios/icon-40.png" width="40" height="40" />
<icon platform="ios" src="res/icons/ios/icon-40-2x.png" width="80" height="80" />
<icon platform="ios" src="res/icons/ios/icon-87.png" width="87" height="87" />
<icon platform="ios" src="res/icons/ios/icon-50.png" width="50" height="50" />
<icon platform="ios" src="res/icons/ios/icon-50-2x.png" width="100" height="100" />
<icon platform="ios" src="res/icons/ios/icon.png" width="57" height="57" />
<icon platform="ios" src="res/icons/ios/icon-2x.png" width="114" height="114" />
<icon platform="ios" src="res/icons/ios/icon-60.png" width="60" height="60" />
<icon platform="ios" src="res/icons/ios/icon-60-2x.png" width="120" height="120" />
<icon platform="ios" src="res/icons/ios/icon-60-3x.png" width="180" height="180" />
<icon platform="ios" src="res/icons/ios/icon-72.png" width="72" height="72" />
<icon platform="ios" src="res/icons/ios/icon-72-2x.png" width="144" height="144" />
<icon platform="ios" src="res/icons/ios/icon-76.png" width="76" height="76" />
<icon platform="ios" src="res/icons/ios/icon-76-2x.png" width="152" height="152" />
<splash platform="ios" src="res/screens/ios/screen-iphone-portrait.png" width="320" height="480" />
<splash platform="ios" src="res/screens/ios/screen-iphone-portrait-2x.png" width="640" height="960" />
<splash platform="ios" src="res/screens/ios/screen-iphone-portrait-568h-2x.png" width="640" height="1136" />
<splash platform="ios" src="res/screens/ios/screen-iphone-portrait-667h.png" width="750" height="1334" />
<splash platform="ios" src="res/screens/ios/screen-iphone-portrait-736h.png" width="1242" height="2208" />
<splash platform="ios" src="res/screens/ios/screen-ipad-portrait.png" width="768" height="1024" />
<splash platform="ios" src="res/screens/ios/screen-ipad-portrait-2x.png" width="1536" height="2048" />
<splash platform="ios" src="res/screens/ios/screen-iphone-landscape.png" width="480" height="320" />
<splash platform="ios" src="res/screens/ios/screen-iphone-landscape-2x.png" width="960" height="640" />
<splash platform="ios" src="res/screens/ios/screen-iphone-landscape-568h-2x.png" width="1136" height="640" />
<splash platform="ios" src="res/screens/ios/screen-iphone-landscape-667h.png" width="1334" height="750" />
<splash platform="ios" src="res/screens/ios/screen-iphone-landscape-736h.png" width="2208" height="1242" />
<splash platform="ios" src="res/screens/ios/screen-ipad-landscape.png" width="1024" height="768" />
<splash platform="ios" src="res/screens/ios/screen-ipad-landscape-2x.png" width="2048" height="1536" />
</platform>
<access origin="*" />
<access origin="tel:*" launch-external="yes" />
<allow-navigation href="*" />
<allow-intent href="*" />
<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="*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<engine name="android" spec="~5.1.1" />
我使用Phonegap Build。
只有在打开通知之前打开应用程序才会出现问题。如果我从通知中打开应用程序,一切正常,直到我再次关闭应用程序。
答案 0 :(得分:0)
当我使用&#34; cordova-plugin-pushplugin&#34;当我从通知中打开应用程序时,我必须编辑几个类才能从索引中打开不同的html。
我必须在PushHandlerActivity.java中编辑方法forceMainActivityReload()添加一个intent然后在MainActivity.java中获取该意图,以查看应用程序是从图标还是通知打开的。
你可能会从该课程及其方法中得到一些东西,我不记得它究竟做了什么,但它可能对你有帮助。