Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49186

$scope.go not work on Android 5.0.1 (s4)

$
0
0

@hamza_tahir wrote:

Hey everyone ,

I have created an android application using ionic framework with phone-gap , right now am using pushplugin to for Push notifications , I want to change the state when a notification is received and have achieved it and got it working on emulator as well as on other devices also but unfortunately when I tested my application on Android (5.0.1) Samsung S4 "$scope.go" is not triggered can anyone suggest a workaround for this problem and let me know what am doing wrong

Here's what am doing:

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

.run(function($ionicPlatform,$rootScope,$cordovaPush,$ionicPopup,$state) {

  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if (window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
      cordova.plugins.Keyboard.disableScroll(true);

    }
    if (window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleDefault();
    }
  //push notifications
  var push = PushNotification.init({"android": {"senderID": "xxxxxxxxxx"},
		    "ios": {"alert": "true", "badge": "true", "sound": "true"}, "windows": {}});

		push.on('registration', function(data) {
		    console.log(data.registrationId);
		});

		push.on('notification', function(data) {
		    if (data.additionalData.id) {

			// $state.go("app.detail_push",{'newId': data.additionalData.id});

		      } else {
			document.location.href = "index.html";

		      }


		});

		push.on('error', function(e) {
		    console.log(e.message);
		});
  });
})

Routes:

.config(function($stateProvider, $urlRouterProvider) {
  $stateProvider
  .state('app.detail_push', {
    url: '/newsdetail_push/:newsId',
    views: {
      'menuContent': {
        templateUrl: 'templates/playlist.html',
        controller: 'NewsDetail'
      }
    }
  })
  $urlRouterProvider.otherwise('/app/playlists');
});

Thanks in advance :slight_smile:

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 49186

Trending Articles