使用OneSignal的PhoneGap Build无法正常工作

时间:2016-08-03 03:59:52

标签: phonegap-build onesignal

我正在使用PhoneGap Build with OneSignal,但它无效。它仅显示第一条警报消息。

这是代码: https://github.com/claudiosw/ZumitApp/

你可以在这里下载应用程序: https://build.phonegap.com/apps/2193000/builds

此处也粘贴代码:

文件config.xml:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.zumitapp" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">

    <name>ZumitApp</name>
    <description>Tenha Mais Resultados</description>
    <author email="claudiosw@" href="http://zumitapp.com/App">Claudio Shigueo Watanabe</author>

    <preference name="phonegap-version" value="cli-6.3.0" />
    <feature name="http://api.phonegap.com/1.0/device" />

    <preference name="orientation"                value="portrait" />       <!-- all: default means both landscape and portrait are enabled -->

    <gap:plugin name="org.apache.cordova.device" />
    <gap:plugin name="org.apache.cordova.camera" />
    <gap:plugin name="org.apache.cordova.media-capture" />
    <gap:plugin name="org.apache.cordova.file" />
    <gap:plugin name="org.apache.cordova.file-transfer" />
    <gap:plugin name="org.apache.cordova.splashscreen" />
    <gap:plugin name="org.apache.cordova.contacts" />
    <gap:plugin name="org.apache.cordova.geolocation" />
    <gap:plugin name="org.apache.cordova.inappbrowser" />
    <gap:plugin name="org.apache.cordova.dialogs" />
    <gap:plugin name="org.apache.cordova.vibration" />
    <gap:plugin name="org.apache.cordova.network-information" />
    <!--gap:plugin name="com.simplec.plugins.localnotification" /-->
        <!--plugin name="com.onesignal.plugins.onesignal" spec="1.5.0" source="pgb" /-->
        <!--plugin name="com.onesignal.plugins.onesignal" spec="1.9.0" source="pgb" /-->
        <gap:plugin name="onesignal-cordova-plugin-pgb-compat" source="npm" /> 
        <gap:plugin name="cordova-plugin-googleplayservices" source="npm" /> 
        <gap:plugin name="cordova-plugin-android-support-v4" source="npm" />
<!--gap:plugin name="onesignal-cordova-plugin" source="npm" /-->

<!-- 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="android-build-tool" value="gradle" /-->


    <icon src="icon.png" />

    <icon src="res/icons/ios/Icon.png" gap:platform="ios" width="57" height="57" />
    <icon src="res/icons/ios/Icon@2x.png" gap:platform="ios" width="114" height="114" />    
    <icon src="res/icons/ios/Icon-72.png" gap:platform="ios" width="72" height="72" />
    <icon src="res/icons/ios/Icon-72@2x.png" gap:platform="ios" width="144" height="144" />

    <icon src="res/icons/android/drawable-ldpi/Icon.png" gap:platform="android" gap:density="ldpi" />
    <icon src="res/icons/android/drawable-mdpi/Icon.png" gap:platform="android" gap:density="mdpi" />
    <icon src="res/icons/android/drawable-hdpi/Icon.png" gap:platform="android" gap:density="hdpi" />
    <icon src="res/icons/android/drawable-xdpi/Icon.png" gap:platform="android" gap:density="xhdpi" />

    <gap:splash src="ZumitApp_grande.jpg" />

    <gap:splash src="res/screen/android/drawable-ldpi/splash.png"  gap:platform="android" gap:density="ldpi" />
    <gap:splash src="res/screen/android/drawable-mdpi/splash.png"  gap:platform="android" gap:density="mdpi" />
    <gap:splash src="res/screen/android/drawable-hdpi/splash.png"  gap:platform="android" gap:density="hdpi" />
    <gap:splash src="res/screen/android/drawable-xdpi/splash.png" gap:platform="android" gap:density="xhdpi" />

    <gap:splash src="res/screen/ios/Default.png" gap:platform="ios" width="320" height="480" />
    <gap:splash src="res/screen/ios/Default@2x.png" gap:platform="ios" width="680" height="960" />
    <gap:splash src="res/screen/ios/Deafult-568h-2x.png" gap:platform="ios" width="640" height="1136" />

    <preference name="stay-in-webview" value="true" />
    <content src="index.html" />
    <access origin="*" subdomains="true" />
    <allow-navigation href="*" />
</widget>

文件index.html:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>ZumitApp</title>
    <script src="phonegap.js"></script>
    <script src="jquery.min.js"></script>
    <script>
        document.addEventListener("deviceready", onDeviceReady, false); 
function onDeviceReady() {
            // Now safe to use the Codova API

  // Enable to debug issues.
  alert("teste0");
  window.plugins.OneSignal.setLogLevel({logLevel: 4, visualLevel: 4});
  alert("teste1");

  var notificationOpenedCallback = function(jsonData) {
    console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
  };
alert("teste2");
  window.plugins.OneSignal.init("22a70849-091e-4eca-8b5b-e7fc5821f95b",
                                 {googleProjectNumber: "428050097085"},
                                 notificationOpenedCallback);
  alert("teste3");
  // Show an alert box if a notification comes in when the user is in your app.
  window.plugins.OneSignal.enableInAppAlertNotification(true);
  //alert("teste4");
     window.location="http://zumitapp.com/App"; 
//alert("teste5");
}
    </script>
  </head>
  <body>

    <header class="bar bar-nav">
      <h1 class="title">Boas-vindas ao ZumitApp</h1>
    </header>

    <h2>Aguarde. Carregando...</h2>


  </body>
</html>

我试过调试但是没有成功。也许是因为我的智能手机很旧(LG-P705)或桌面(Windows Vista)。

非常感谢你!

0 个答案:

没有答案