One Signal Phonegap does not work

Asked

Viewed 344 times

0

I am updating a phonegap app, it compiles in the cloud without problems, but when trying to login that I am using One Signal to do it, it does not access, it is not a problem with the api because I declared that I sent an error message. The version that is running does not present the error, only when compiling in the zip on the phonegap site, I tried to build the previous versions, and if the build is made the old version also presents the error. Someone can tell me if there’s something wrong with the xml. Or someone who has more experience with One Signal to tell me what it can be, follow xml and js controler:

                        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <widget id="com.vectra.odontomedica" version="1.0.6" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:gap="http://phonegap.com/ns/1.0">
      <name>Vectra</name>
       <description>
           Desenvolvimento por Augusto Xavier
       </description>
       <author email="[email protected]" href="">
         Augusto Xavier
       </author>
       <content src="index.html"/>
        <access origin="*"/>

         <preference name="android-windowSoftInputMode" value="adjustPan" />
         <preference name="webviewbounce" value="false"/>
        <preference name="UIWebViewBounce" value="false"/>
        <preference name="DisallowOverscroll" value="true"/>
        <preference name="android-minSdkVersion" value="16"/>
        <preference name="android-targetSdkVersion" value="23"/>
        <preference name="BackupWebStorage" value="none"/>
        <preference name="SplashScreen" value="screen"/>
        <preference name="SplashScreenDelay" value="3000"/>
        <feature name="StatusBar">
          <param name="ios-package" value="CDVStatusBar" onload="true"/>
             </feature>
                <allow-intent href="http://*/*" />
               <allow-intent href="https://*/*" />
               <allow-intent href="tel:*" />
               <allow-intent href="sms:*" />
               <allow-intent href="mailto:*" />
              <allow-intent href="geo:*" />

                <plugin name="cordova-plugin-splashscreen" spec="4.0.0" />
                <plugin name="cordova-plugin-whitelist" spec="1.3.0" />
                <plugin name="ionic-plugin-keyboard" spec="2.2.1" />
                <plugin name="onesignal-cordova-plugin" spec="2.0.6" />



                       <preference name="phonegap-version" value="cli-6.3.0" />
                      <preference name="android-build-tool" value="gradle" />
                      <preference name="fullscreen" value="false" />

                           <platform name="android">
                           <preference name="SplashScreen" value="screen"/>
                           <preference name="SplashScreenDelay" value="3000"/>
                           <!-- you can use any density that exists in the Android project -->
                            <splash src="res/screen/android/splash-land-hdpi.png" density="land-hdpi"/>
                            <splash src="res/screen/android/splash-land-ldpi.png" density="land-ldpi"/>
                            <splash src="res/screen/android/splash-land-mdpi.png" density="land-mdpi"/>
                            <splash src="res/screen/android/splash-land-xhdpi.png" density="land-xhdpi"/>

                            <splash src="res/screen/android/splash-port-hdpi.png" density="port-hdpi"/>
                            <splash src="res/screen/android/splash-port-ldpi.png" density="port-ldpi"/>
                            <splash src="res/screen/android/splash-port-mdpi.png" density="port-mdpi"/>
                            <splash src="res/screen/android/splash-port-xhdpi.png" density="port-xhdpi"/>
                              </platform>

                                 <platform name="ios">
                                    <!-- images are determined by width and height. The following are supported -->
                                   <splash src="res/screen/ios/Default~iphone.png" width="320" height="480"/>
                                   <splash src="res/screen/ios/Default@2x~iphone.png" width="640" height="960"/>
                                   <splash src="res/screen/ios/Default-Portrait~ipad.png" width="768" height="1024"/>
                                   <splash src="res/screen/ios/Default-Portrait@2x~ipad.png" width="1536" height="2048"/>
                                   <splash src="res/screen/ios/Default-Landscape~ipad.png" width="1024" height="768"/>
                                   <splash src="res/screen/ios/Default-Landscape@2x~ipad.png" width="2048" height="1536"/>
                                   <splash src="res/screen/ios/Default-568h@2x~iphone.png" width="640" height="1136"/>
                                   <splash src="res/screen/ios/Default-667h.png" width="750" height="1334"/>
                                   <splash src="res/screen/ios/Default-736h.png" width="1242" height="2208"/>
                                   <splash src="res/screen/ios/Default-Landscape-736h.png" width="2208" height="1242"/>
                                      </platform>


                                     <icon gap:platform="ios" src="res/icons/ios/icon-small.png" width="29" height="29" />
                                     <icon gap:platform="ios" src="res/icons/ios/icon-small-2x.png" width="58" height="58" />
                                     <icon gap:platform="ios" src="res/icons/ios/icon-40.png" width="40" height="40" />
                                     <icon gap:platform="ios" src="res/icons/ios/icon-40-2x.png" width="80" height="80" />
                                     <icon gap:platform="ios" src="res/icons/ios/icon-50.png" width="50" height="50" />
                                     <icon gap:platform="ios" src="res/icons/ios/icon-50-2x.png" width="100" height="100" />
                                     <icon gap:platform="ios" src="res/icons/ios/icon.png" width="57" height="57" />
                                     <icon gap:platform="ios" src="res/icons/ios/icon-2x.png" width="114" height="114" />
                                     <icon gap:platform="ios" src="res/icons/ios/icon-60.png" width="60" height="60" />
                                     <icon gap:platform="ios" src="res/icons/ios/icon-60-2x.png" width="120" height="120" />
                                     <icon gap:platform="ios" src="res/icons/ios/icon-60-3x.png" width="180" height="180" />
                                     <icon gap:platform="ios" src="res/icons/ios/icon-72.png" width="72" height="72" />
                                     <icon gap:platform="ios" src="res/icons/ios/icon-72-2x.png" width="144" height="144" />
                                     <icon gap:platform="ios" src="res/icons/ios/icon-76.png" width="76" height="76" />
                                     <icon gap:platform="ios" src="res/icons/ios/icon-76-2x.png" width="152" height="152" />

                                           <icon gap:platform="android" gap:qualifier="ldpi" src="res/icons/android/icon-36-ldpi.png"/>
                                           <icon gap:platform="android" gap:qualifier="mdpi" src="res/icons/android/icon-48-mdpi.png"/>
                                           <icon gap:platform="android" gap:qualifier="hdpi" src="res/icons/android/icon-72-hdpi.png"/>
                                           <icon gap:platform="android" gap:qualifier="xhdpi" src="res/icons/android/icon-96-xhdpi.png"/>
                                           <icon gap:platform="android" gap:qualifier="xxhdpi" src="res/icons/android/icon-144-xxhdpi.png"/>
                                          <icon gap:platform="android" gap:qualifier="xxxhdpi" src="res/icons/android/icon-192-xxxhdpi.png"/>
                                          </widget>

The Controller js:

                                                        (function () {
'use strict';

angular
    .module('LoginModule', ['CommonModule'])
    .controller('LoginController', LoginController);

LoginController.$inject = ['$scope', 'CommonService', '$ionicPopup', '$ionicLoading', '$state'];
function LoginController($scope, CommonService, $ionicPopup, $ionicLoading, $state) {
    //CommonService.sair();
    //CommonService.verificaLogado();
    $scope.popup = {};
    $scope.gravarSenha = false;
    $scope.esqueciData = {};
    var isGravarSenha = localStorage.getItem("gravarSenha");

    if (isGravarSenha != null && isGravarSenha != undefined && isGravarSenha != "") {
        isGravarSenha = JSON.parse(isGravarSenha);
        $scope.gravarSenha = true;
        $state.go("app.home");
    }

    var dadosOdonto = JSON.parse(localStorage.getItem("dadosOdonto"));

    if (dadosOdonto != undefined && dadosOdonto.Url != null) {
        $scope.logotipo = dadosOdonto.Url + "/logotipo.png";
    } else {
        $scope.logotipo = "img/logotipo.png";
    }

    $scope.cadastroNovo = function () {
        localStorage.setItem("configuracoes", "false");
        $state.go('cadastro');
    }

    $scope.clicarSenha = function (gravar) {
        $scope.gravarSenha = gravar;
    }

    $scope.logar = function (data) {
        $ionicLoading.show({
            template: 'Efetuando o login...'
        });
        window.plugins.OneSignal.getIds(function (ids) {
            data.deviceId = ids.userId;

            //data.deviceId = "";
            var chamaApi = CommonService.api("http://api.agafcomunicacao.com.br/api/login/entrar", data);
            chamaApi.get(data).$promise.then(function (retorno) {
                $ionicLoading.hide();
                if (retorno.Cro != undefined) {
                    if ($scope.gravarSenha == true) {
                        localStorage.setItem("gravarSenha", JSON.stringify(data));
                    } else {
                        localStorage.removeItem("gravarSenha");
                    }
                    localStorage.setItem("logado", JSON.stringify(retorno));
                    $state.go('app.home');
                } else {
                    $ionicPopup.alert({
                        title: 'Mensagem',
                        template: retorno.Mensagem
                    });
                }
            }, function (error) {
                $ionicLoading.hide();
                $ionicPopup.alert({
                    title: 'Ocorreu um erro!',
                    template: 'Erro ao realizar integração com a Api! Tente novamente mais tarde!'
                });
            });
        });
    }

    $scope.esqueciSenha = function () {
        var myPopup = $ionicPopup.show({
            template: '<input type="text" ng-model="popup.croEsqueciSenha" placeholder="Cro: ">',
            title: 'Recuperar senha pelo Cro',
            subTitle: 'Digite seu Cro',
            scope: $scope,
            buttons: [
                { text: 'Cancelar' },
                {
                    text: '<b>Solicitar</b>',
                    type: 'button-positive',
                    onTap: function (e) {
                        if (!$scope.popup.croEsqueciSenha) {
                            e.preventDefault();
                        } else {
                            return $scope.popup.croEsqueciSenha;
                        }
                    }
                }
            ]
        });

        myPopup.then(function (res) {
            if (res != undefined) {
                $ionicLoading.show({
                    template: 'Aguarde...'
                });
                var data = {};
                data.cro = res;
                var chamaApi = CommonService.api("http://api.agafcomunicacao.com.br/api/login/esquecisenha", data);
                chamaApi.get(data).$promise.then(function (retorno) {
                    $ionicLoading.hide();
                    $scope.popup = {};
                    $ionicPopup.alert({
                        title: 'Mensagem',
                        template: retorno.Mensagem
                    });
                }, function (error) {
                    $ionicLoading.hide();
                    $ionicPopup.alert({
                        title: 'Ocorreu um erro!',
                        template: 'Erro ao realizar integração com a Api! Tente novamente mais tarde!'
                    });
                });
            }
        });

    }

    $scope.recuperarSenha = function () {
        var myPopup = $ionicPopup.show({
            template: '<input type="text" ng-model="esqueciData.cro" placeholder="Cro:"></br><input type="text" ng-model="esqueciData.codigo" placeholder="Código:"> </br><input type="password" ng-model="esqueciData.novaSenha" placeholder="Nova Senha:">',
            title: 'Trocar Senha',
            subTitle: 'Digite o código enviado por e-mail e a nova senha',
            scope: $scope,
            buttons: [
                { text: 'Cancelar' },
                {
                    text: '<b>Recuperar</b>',
                    type: 'button-positive',
                    onTap: function (e) {
                        if (!$scope.esqueciData.cro || !$scope.esqueciData.codigo || !$scope.esqueciData.novaSenha) {
                            e.preventDefault();
                        } else {
                            var data = {};
                            data.codigo = $scope.esqueciData.codigo;
                            data.cro = $scope.esqueciData.cro;
                            data.novaSenha = $scope.esqueciData.novaSenha;
                            return data;
                        }
                    }
                }
            ]
        });


        myPopup.then(function (res) {
            if (res != undefined) {
                $ionicLoading.show({
                    template: 'Aguarde...'
                });
                var chamaApi = CommonService.api("http://api.agafcomunicacao.com.br/api/login/alterarsenha", res);
                chamaApi.get(res).$promise.then(function (retorno) {
                    $ionicLoading.hide();
                    $scope.esqueciData = {};
                    $ionicPopup.alert({
                        title: 'Mensagem',
                        template: retorno.Mensagem
                    });
                }, function (error) {
                    $ionicLoading.hide();
                    $ionicPopup.alert({
                        title: 'Ocorreu um erro!',
                        template: 'Erro ao realizar integração com a Api! Tente novamente mais tarde!'
                    });
                });
            }
        });

    }

}
             })();

1 answer

0


I discovered the solution the code was discontinued, adjusted being the documentation of Onesignal and installed the plugin Cordova-plugin-file that is responsible for saving the information of deviceid, so I managed to solve the problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.