离子网页过渡不工作到页面推送功能 [英] Ionic page transition not working to page with push feature

查看:259
本文介绍了离子网页过渡不工作到页面推送功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序实现的android推前台,它工作得很好,只要该应用程序开始于该页面。但是,如果你导航到推送通知实施的过渡​​不工作收件箱页面。

过渡工作良好,没有推动实施。

我不知道是否有人有类似的问题实现的功能。

  .controller(BuzonMenuCtrl',函数($范围,$窗口,$状态,$ ionicPlatform){
  $ scope.botonBuzon =功能(){
    $ state.go('buzon');
  };
})

.controller('BuzonCtrl',函数($范围,$ rootScope,$窗口,$ ionicActionSheet,$ ionicPopup,$状态,$ HTTP,的DataFactory,pushFactory){

  // Activacion德拉funcionalidad推
  pushFactory.funcionalidadPush();

}
 

factorys.js

  .factory(pushFactory',['$ rootScope,$ HTTP,$状态,$ ionicLoading','$ ionicPlatform','$ cordovaPush', 的DataFactory,
                          功能($ rootScope,$ HTTP,$状态,$ ionicLoading,$ ionicPlatform,$ cordovaPush,的DataFactory){

  / * Objeto德尔工厂* /
  变种的fac = {};

  fac.funcionalidadPush =功能(){
    如果(ionic.Platform.isAndroid()){
      VAR androidConfig = {
        senderID:94XXXXXXXXXX,
        欧洲央行:casosPush
      };

      $ rootScope.data.pushplatform =GCM;
      警报('ENTRO恩MODO Android的);

    };

    如果(ionic.Platform.isIOS()){
      警报('ENTRO恩摩多的iOS');
    };

    $ ionicPlatform.ready(函数(){
      $ cordovaPush.register(androidConfig)。然后(函数(结果){
        // 成功
      },功能(错误){
        // 错误
      })

      window.casosPush =功能(通知){
        开关(notification.event){
          案注册:
            如果(notification.regid.length大于0){
              警报(注册ID ='+ notification.regid);
              $ rootScope.data.token = notification.regid;

            }
            打破;

          案消息:
            //这是实际的推送通知。其格式取决于从推送服务器中的数据模型
            //警报(消息='+ notification.message +'MSGCOUNT ='+ notification.msgcnt);
            $ rootScope.mensajes.push(通知);
            打破;

          案错误:
            警报(GCM误差='+ notification.msg);
            打破;

          默认:
            警报('未知GCM事件已发生');
            打破;
        }
      };

      //警告:危险的注销(结果tokenID的损失)
      $ cordovaPush.unregister(选项)。然后(函数(结果){
        // 成功!
      },功能(错误){
              // 错误
      })

    }, 假);
  };


  返回FAC;

}]);
 

App.js

  angular.module(notPush',['离子','ngCordova','notPush.controllers'])

.RUN(函数($ ionicPlatform){
  $ ionicPlatform.ready(函数(){
    如果(window.cordova&安培;&安培; window.cordova.plugins.Keyboard){
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(真正的);
    }
    如果(window.StatusBar){
      StatusBar.styleDefault();
    }
  });
})

的.config(函数($ stateProvider,$ urlRouterProvider){

  $ stateProvider

  .state('闪',{
    网址:'/飞溅,
    templateUrl:模板/ splash.html',
    控制器:SplashCtrl
  })

  .state('buzonMenu',{
    网址:'/ buzonMenu,
    templateUrl:模板/ buzonMenu.html',
    控制器:BuzonMenuCtrl
  })

  .state('buzon',{
    网址:'/ buzon,
    templateUrl:模板/ buzon.html',
    控制器:BuzonCtrl
  })

  //如果上述状态相匹配,以此作为后备:
  $ urlRouterProvider.otherwise('/ buzonMenu');

});
 

修改

至于建议中我尝试了意见

  $ window.location.reload(真正的);
 

这并不做任何事情,除了使屏幕闪烁,并且还

  $ state.go($ state.current,{},{重装:真});
 

这attemps重新加载页面,但只能在一个腐败的国家,它加载的白色背景和按钮(无颜色),但仅此而已。

编辑2 一些澄清:

  1. 的$ C $下推送通知写在buzon_page控制器,这是有问题的页面中。
  2. 当我说的的转变不工作的我的意思是页面没有加载,但该页面的所有警报仍然触发,推令牌还是检索。是一个可视化的问题,认为不会加载。
  3. 的问题是不相关的HTTP调用,因为他们正在评论道。

修改3

我感动控制器内部有它(因为它应该是,我猜),但有没有改善的通知code到工厂来代替。

我添加的结果亚行logcat 在发行时。有2个东西,我毫无遗漏的注意:

  1. 它显示了一个的ReferenceError:不定义选项,在factorys.js
  2. 它显示了一些OpenGLRenderer问题。

      1219 AudioTrackW¯¯AUDIO_OUTPUT_FLAG_FAST否认客户端
    2531 PushPlugin V执行:行动=寄存器
    2531 PushPlugin V执行:数据= [{senderID:ID删除了隐私问题,欧洲央行:casosPush}]
    2531 PushPlugin V执行:o = {senderID:ID删除了隐私问题,欧洲央行:casosPush}
    2531 PushPlugin V执行:ECB = casosPush senderID = ID删除了隐私问题
    2531 GCMRegistrarð重置退避的ID删除了隐私问题
    1219 InputMethodManager ..W¯¯窗口已经集中,忽略了聚焦增益:com.android.internal.view.IInputMethodClient$Stub$Proxy@df31fbd属性= NULL,令牌=一
                                   ndroid.os.BinderProxy@28f2dc02
    2531 GCMRegistrar V注册应用程序ID删除了发件人ID删除了隐私问题隐私问题
    2531 SystemWebChromeCli .. D档:///android_asset/www/lib/ionic/js/ionic.bundle.js:行20243:的ReferenceError:选择没有定义
    2531 SystemWebChromeCli ..Ð在文件:///android_asset/www/js/factorys.js:214:31
    2531 SystemWebChromeCli ..Ð在文件:///android_asset/www/lib/ionic/js/ionic.bundle.js:44687:19
    2531 SystemWebChromeCli ..Ð在Object.ionic.Platform.ready(文件:///android_asset/www/lib/ionic/js/ionic.bundle.js:2120:9)
    2531 SystemWebChromeCli ..Ð在Object.self.ready(文件:///android_asset/www/lib/ionic/js/ionic.bundle.js:44685:26)
    2531 SystemWebChromeCli ..Ð在Object.fac.funcionalidadPush(文件:///android_asset/www/js/factorys.js:166:20)
    2531 SystemWebChromeCli ..Ð在全新<匿名> (文件:///android_asset/www/js/controllers.js:440:15)
    2531 SystemWebChromeCli ..Ð在调用(文件:///android_asset/www/lib/ionic/js/ionic.bundle.js:12821:17)
    2531 SystemWebChromeCli ..Ð在Object.instantiate(文件:///android_asset/www/lib/ionic/js/ionic.bundle.js:12829:27)
    2531 SystemWebChromeCli ..Ð在文件:///android_asset/www/lib/ionic/js/ionic.bundle.js:17098:28
    2531 SystemWebChromeCli ..Ð在self.appendViewElement(文件:///android_asset/www/lib/ionic/js/ionic.bundle.js:48110:24)
    2531铬我[信息:控制台(20243)]的ReferenceError:选项是没有定义
    2531铬我的文件:///android_asset/www/js/factorys.js:214:31
    2531铬我的文件:///android_asset/www/lib/ionic/js/ionic.bundle.js:44687:19
    2531铬我在Object.ionic.Platform.ready(文件:///android_asset/www/lib/ionic/js/ionic.bundle.js:2120:9)
    2531铬我在Object.self.ready(文件:///android_asset/www/lib/ionic/js/ionic.bundle.js:44685:26)
    2531铬我在Object.fac.funcionalidadPush(文件:///android_asset/www/js/factorys.js:166:20)
    2531铬我在全新<匿名> (文件:///android_asset/www/js/controllers.js:440:15)
    2531铬我在调用(文件:///android_asset/www/lib/ionic/js/ionic.bundle.js:12821:17)
    2531铬我在Object.instantiate(文件:///android_asset/www/lib/ionic/js/ionic.bundle.js:12829:27)
    2531铬我的文件:///android_asset/www/lib/ionic/js/ionic.bundle.js:17098:28
    2531铬我在self.appendViewElement(文件:///android_asset/www/lib/ionic/js/ionic.bundle.js:48110:24),来源:文件:/// android_asset / WWW / lib中/离子
                                   /js/ionic.bundle.js(20243)
    1604 GCMðGcmService启动意向书{行动= com.google.android.c2dm.intent.REGISTER PKG = com.google.android.gms CMP = com.google.android.gms / .gcm.GcmServi
                                   CE(有群众演员)} com.google.android.c2dm.intent.REGISTER
    2531 GCMBroadcastReceiver V的onReceive:com.google.android.c2dm.intent.REGISTRATION
    2531 GCMRegistrar v安装重试接收器类的名称com.plugin.gcm.CordovaGCMBroadcastReceiver
    2531 GCMBroadcastReceiver V GCM IntentService类:com.plugin.gcm.GCMIntentService
    2531 GCMBaseIntentService V获取wakelock
    2531 GCMBaseIntentService V意图服务名称:GCMIntentService-GCMIntentService-1
    2531 GCMRegistrar V接收器注册
    2531 GCMBaseIntentServiceðhandleRegistration:registrationId = TOKEN删除了隐私问题,错误= NULL,未注册= NULL
    2531 GCMRegistrarð重置退避的ID删除了隐私问题
    2531 GCMRegistrar V保存REGID上的应用程序版本10
    2531 GCMIntentService V onRegistered:TOKEN删除了隐私问题
    2531 GCMIntentService V onRegistered:{事件:注册,REGID:TOKEN删除了隐私问题}
    2531 PushPlugin V sendJavascript:JavaScript的:casosPush({事件:注册,REGID:TOKEN删除了隐私问题})
    2531 GCMBaseIntentService V释放wakelock
    2531 EGL_emulationW¯¯eglSurfaceAttrib未实现
    2531 OpenGLRendererW¯¯无法对表面0xa4cdd7e0设置EGL_SWAP_BEHAVIOR,错误= EGL_SUCCESS
    1219 AudioTrackW¯¯AUDIO_OUTPUT_FLAG_FAST否认客户端
    1219 InputMethodManager ..W¯¯窗口已经集中,忽略了聚焦增益:com.android.internal.view.IInputMethodClient$Stub$Proxy@35215d0a属性= NULL,标记=
                                   android.os.BinderProxy@28f2dc02
     

解决方案

我解决了这个问题由于在意见的帮助,所以我要在这里写的解决方案。

的意见建议此 code 这样的推送通知是尽快启动该应用程序将启动。

我会在这里添加自己的code以防万一,警报和$ rootScope变量是用于测试目的。

  / *
   app.js
* /
angular.module('notPush',['离子','notPush.controllers','notPush.factorys'])

.RUN(函数($ ionicPlatform,$ rootScope){
  $ ionicPlatform.ready(函数(){

    如果(window.cordova&安培;&安培; window.cordova.plugins.Keyboard){
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(真正的);
    }

    如果(window.StatusBar){
      StatusBar.styleDefault();
    }

    $ rootScope.mensajes = [];

    //推code
    尝试{
      VAR pushNotification = window.plugins.pushNotification;
    }赶上(前){

    }
    VAR successfn =功能(结果){
      警报(成功:+结果);
    };
    VAR errorfn =功能(结果){
      window.alert(错误:+结果);
    };
    window.casosPush =功能(通知){
      开关(notification.event){
        案注册:
          如果(notification.regid.length大于0){
            警报(注册ID ='+ notification.regid);
          }
          打破;

        案消息:
          警报(JSON.stringify([通知]));
          $ rootScope.mensajes.push(通知);
          打破;

        案错误:
          警报(GCM误差='+ notification.msg);
          打破;

        默认:
          警报('未知GCM事件已发生');
          打破;
      }
    };
    尝试{
      pushNotification.register(
        successfn,
        errorfn,
        {
          senderID:94XXXXXXXXXX,
          欧洲央行:window.casosPush
        }
      );
    }赶上(通知){

    }
  });
})

的.config(函数($ stateProvider,$ urlRouterProvider){

  $ stateProvider

  .state('闪',{
    网址:'/飞溅,
    templateUrl:模板/ splash.html',
    控制器:SplashCtrl
  })

  .state('registro',{
    网址:'/ registro,
    templateUrl:模板/ registro.html',
    控制器:RegistroCtrl
  })

  .state('buzonMenu',{
    网址:'/ buzonMenu,
    templateUrl:模板/ buzonMenu.html',
    控制器:BuzonMenuCtrl
  })

  .state('buzon',{
    网址:'/ buzon,
    templateUrl:模板/ buzon.html',
    控制器:BuzonCtrl
  })

  .state('detallesSimple',{
    网址:'/ detallesSimple,
    templateUrl:模板/ detallesSimple.html',
    控制器:DetallesCtrl
  })

  .state('detallesDoble',{
    网址:'/ detallesDoble,
    templateUrl:模板/ detallesDoble.html',
    控制器:DetallesCtrl
  })

  .state('detallesWV',{
    网址:'/ detallesWV,
    templateUrl:模板/ detallesWV.html',
    控制器:DetallesWVCtrl
  })

  //如果上述状态相匹配,以此作为后备:
  $ urlRouterProvider.otherwise('/飞溅');

});
 

I implemented android push reception in my app, and it works well as long as the app starts at that page. But if you navigate to the inbox page where the push notifications are implemented the transition doesn't work.

The transition worked well without the push implementation.

I wonder if someone has had a similar problem implementing features.

.controller('BuzonMenuCtrl', function($scope, $window, $state, $ionicPlatform) {
  $scope.botonBuzon = function(){
    $state.go('buzon');
  };
})

.controller('BuzonCtrl', function($scope, $rootScope, $window, $ionicActionSheet, $ionicPopup, $state, $http, dataFactory, pushFactory) {

  // Activacion de la funcionalidad push
  pushFactory.funcionalidadPush();

}

factorys.js

.factory('pushFactory', ['$rootScope','$http','$state','$ionicLoading','$ionicPlatform','$cordovaPush','dataFactory',
                          function($rootScope,$http,$state,$ionicLoading,$ionicPlatform,$cordovaPush,dataFactory) {

  /* Objeto del factory */
  var fac = {};

  fac.funcionalidadPush = function(){
    if (ionic.Platform.isAndroid()){
      var androidConfig = {
        "senderID": "94XXXXXXXXXX",
        "ecb": "casosPush"
      };

      $rootScope.data.pushplatform = "gcm";
      alert('Entro en modo Android');

    };

    if (ionic.Platform.isIOS()){
      alert('Entro en modo iOS');
    };

    $ionicPlatform.ready(function() {
      $cordovaPush.register(androidConfig).then(function(result) {
        // Success
      }, function(err) {
        // Error
      })

      window.casosPush = function (notification) {
        switch(notification.event) {
          case 'registered':
            if (notification.regid.length > 0 ) {
              alert('registration ID = ' + notification.regid);
              $rootScope.data.token = notification.regid;

            }
            break;

          case 'message':
            // this is the actual push notification. its format depends on the data model from the push server
            //alert('message = ' + notification.message + ' msgCount = ' + notification.msgcnt);
            $rootScope.mensajes.push(notification);
            break;

          case 'error':
            alert('GCM error = ' + notification.msg);
            break;

          default:
            alert('An unknown GCM event has occurred');
            break;
        }
      };

      // WARNING: dangerous to unregister (results in loss of tokenID)
      $cordovaPush.unregister(options).then(function(result) {
        // Success!
      }, function(err) {
              // Error
      })

    }, false);
  };


  return fac;

}]);

App.js

angular.module('notPush', ['ionic', 'ngCordova', 'notPush.controllers'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
})

.config(function($stateProvider, $urlRouterProvider) {

  $stateProvider

  .state('splash', {
    url: '/splash',
    templateUrl: 'templates/splash.html',
    controller: 'SplashCtrl'
  })

  .state('buzonMenu', {
    url: '/buzonMenu',
    templateUrl: 'templates/buzonMenu.html',
    controller: 'BuzonMenuCtrl'
  })

  .state('buzon', {
    url: '/buzon',
    templateUrl: 'templates/buzon.html',
    controller: 'BuzonCtrl'
  })

  // If none of the above states are matched, use this as the fallback:
  $urlRouterProvider.otherwise('/buzonMenu');

});

EDIT

As suggested in the comments I tried

$window.location.reload(true);

which doesn't do anything except to make the screen blink, and also

$state.go($state.current, {}, {reload: true});

which attemps to reload the page but only in a corrupt state, it loads the white background and the buttons (without color) but nothing else.

EDIT 2 Some clarifications:

  1. The code for push notifications is written inside the buzon_page controller, which is the page that is having trouble.
  2. When I say "the transition doesn't work" I mean that the page doesn't load, but all the alerts of that page are still triggered, and the Push Token is still retrieved. Is a visual problem, the view doesn't load.
  3. The problem is not related to HTTP calls because they are currently commented.

EDIT 3

I moved the notifications code to a factory instead of having it inside the controller (as it should be, I guess) but there is no improvement.

I'm adding the result of adb logcat during the issue. There are 2 things that cought my attention:

  1. It shows a "ReferenceError: options is not defined" at factorys.js
  2. It shows some OpenGLRenderer issue.

    1219             AudioTrack  W  AUDIO_OUTPUT_FLAG_FAST denied by client   
    2531             PushPlugin  V  execute: action=register
    2531             PushPlugin  V  execute: data=[{"senderID":ID DELETED FOR PRIVACY ISSUES,"ecb":"casosPush"}]
    2531             PushPlugin  V  execute: jo={"senderID":ID DELETED FOR PRIVACY ISSUES,"ecb":"casosPush"}
    2531             PushPlugin  V  execute: ECB=casosPush senderID=ID DELETED FOR PRIVACY ISSUES
    2531           GCMRegistrar  D  resetting backoff for ID DELETED FOR PRIVACY ISSUES
    1219   InputMethodManager..  W  Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@df31fbd attribute=null, token = a
                                   ndroid.os.BinderProxy@28f2dc02
    2531           GCMRegistrar  V  Registering app ID DELETED FOR PRIVACY ISSUES of senders ID DELETED FOR PRIVACY ISSUES
    2531   SystemWebChromeCli..  D  file:///android_asset/www/lib/ionic/js/ionic.bundle.js: Line 20243 : ReferenceError: options is not defined
    2531   SystemWebChromeCli..  D  at file:///android_asset/www/js/factorys.js:214:31
    2531   SystemWebChromeCli..  D  at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:44687:19
    2531   SystemWebChromeCli..  D  at Object.ionic.Platform.ready (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:2120:9)
    2531   SystemWebChromeCli..  D  at Object.self.ready (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:44685:26)
    2531   SystemWebChromeCli..  D  at Object.fac.funcionalidadPush (file:///android_asset/www/js/factorys.js:166:20)
    2531   SystemWebChromeCli..  D  at new <anonymous> (file:///android_asset/www/js/controllers.js:440:15)
    2531   SystemWebChromeCli..  D  at invoke (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:12821:17)
    2531   SystemWebChromeCli..  D  at Object.instantiate (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:12829:27)
    2531   SystemWebChromeCli..  D  at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:17098:28
    2531   SystemWebChromeCli..  D  at self.appendViewElement (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:48110:24)
    2531               chromium  I  [INFO:CONSOLE(20243)] "ReferenceError: options is not defined
    2531               chromium  I  at file:///android_asset/www/js/factorys.js:214:31
    2531               chromium  I  at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:44687:19
    2531               chromium  I  at Object.ionic.Platform.ready (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:2120:9)
    2531               chromium  I  at Object.self.ready (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:44685:26)
    2531               chromium  I  at Object.fac.funcionalidadPush (file:///android_asset/www/js/factorys.js:166:20)
    2531               chromium  I  at new <anonymous> (file:///android_asset/www/js/controllers.js:440:15)
    2531               chromium  I  at invoke (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:12821:17)
    2531               chromium  I  at Object.instantiate (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:12829:27)
    2531               chromium  I  at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:17098:28
    2531               chromium  I  at self.appendViewElement (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:48110:24)", source: file:///android_asset/www/lib/ionic
                                   /js/ionic.bundle.js (20243)
    1604                    GCM  D  GcmService start Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms cmp=com.google.android.gms/.gcm.GcmServi
                                   ce (has extras) } com.google.android.c2dm.intent.REGISTER
    2531   GCMBroadcastReceiver  V  onReceive: com.google.android.c2dm.intent.REGISTRATION
    2531           GCMRegistrar  V  Setting the name of retry receiver class to com.plugin.gcm.CordovaGCMBroadcastReceiver
    2531   GCMBroadcastReceiver  V  GCM IntentService class: com.plugin.gcm.GCMIntentService
    2531   GCMBaseIntentService  V  Acquiring wakelock
    2531   GCMBaseIntentService  V  Intent service name: GCMIntentService-GCMIntentService-1
    2531           GCMRegistrar  V  Registering receiver
    2531   GCMBaseIntentService  D  handleRegistration: registrationId = TOKEN DELETED FOR PRIVACY ISSUES, error = null, unregistered = null
    2531           GCMRegistrar  D  resetting backoff for ID DELETED FOR PRIVACY ISSUES
    2531           GCMRegistrar  V  Saving regId on app version 10
    2531       GCMIntentService  V  onRegistered: TOKEN DELETED FOR PRIVACY ISSUES
    2531       GCMIntentService  V  onRegistered: {"event":"registered","regid":TOKEN DELETED FOR PRIVACY ISSUES}
    2531             PushPlugin  V  sendJavascript: javascript:casosPush({"event":"registered","regid":TOKEN DELETED FOR PRIVACY ISSUES})
    2531   GCMBaseIntentService  V  Releasing wakelock
    2531          EGL_emulation  W  eglSurfaceAttrib not implemented
    2531         OpenGLRenderer  W  Failed to set EGL_SWAP_BEHAVIOR on surface 0xa4cdd7e0, error=EGL_SUCCESS
    1219             AudioTrack  W  AUDIO_OUTPUT_FLAG_FAST denied by client
    1219   InputMethodManager..  W  Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@35215d0a attribute=null, token = 
                                   android.os.BinderProxy@28f2dc02
    

解决方案

I solved the problem thanks to the help in the comments, so I'm going to write the solution here.

The comment suggested this code so that the push notifications were activated as soon as the app starts.

I'll add here my own code just in case, the alerts and $rootScope variables are for testing purposes.

/* 
   app.js
*/
angular.module('notPush', ['ionic', 'notPush.controllers', 'notPush.factorys'])

.run(function($ionicPlatform,$rootScope) {
  $ionicPlatform.ready(function() {

    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }

    if(window.StatusBar) {
      StatusBar.styleDefault();
    }

    $rootScope.mensajes = [];

    // Push code
    try{
      var pushNotification = window.plugins.pushNotification;
    } catch (ex){

    }
    var successfn = function(result){
      alert("Success: " + result);
    };
    var errorfn   = function(result){
      window.alert("Error: " + result);
    };
    window.casosPush = function(notification){
      switch (notification.event){
        case 'registered':
          if (notification.regid.length > 0){
            alert('registration ID = ' + notification.regid);
          }
          break;

        case 'message':
          alert(JSON.stringify([notification]));
          $rootScope.mensajes.push(notification);
          break;

        case 'error':
          alert('GCM error = ' + notification.msg);
          break;

        default:
          alert('An unknown GCM event has occurred');
          break;
      }
    };
    try{
      pushNotification.register(
        successfn,
        errorfn,
        {
          "senderID": "94XXXXXXXXXX",
          "ecb"     : "window.casosPush"
        }
      );
    } catch(notification){

    } 
  });
})

.config(function($stateProvider, $urlRouterProvider) {

  $stateProvider

  .state('splash', {
    url: '/splash',
    templateUrl: 'templates/splash.html',
    controller: 'SplashCtrl'
  })

  .state('registro', {
    url: '/registro',
    templateUrl: 'templates/registro.html',
    controller: 'RegistroCtrl'
  })

  .state('buzonMenu', {
    url: '/buzonMenu',
    templateUrl: 'templates/buzonMenu.html',
    controller: 'BuzonMenuCtrl'
  })

  .state('buzon', {
    url: '/buzon',
    templateUrl: 'templates/buzon.html',
    controller: 'BuzonCtrl'
  })

  .state('detallesSimple', {
    url: '/detallesSimple',
    templateUrl: 'templates/detallesSimple.html',
    controller: 'DetallesCtrl'
  })

  .state('detallesDoble', {
    url: '/detallesDoble',
    templateUrl: 'templates/detallesDoble.html',
    controller: 'DetallesCtrl'
  })

  .state('detallesWV', {
    url: '/detallesWV',
    templateUrl: 'templates/detallesWV.html',
    controller: 'DetallesWVCtrl'
  })

  // If none of the above states are matched, use this as the fallback:
  $urlRouterProvider.otherwise('/splash');

});

这篇关于离子网页过渡不工作到页面推送功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆