Search code examples
androidiosangularjscordovaphonegap-plugins

phone gap register even not firing on iOS


So my app works flawlessly on android. But when i test on a real iOS device, I cannot register the device to get the device token. Here is my code:

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

      // Don't remove this line unless you know what you are doing. It stops the viewport
      // from snapping when text inputs are focused. Ionic handles this internally for
      // a much nicer keyboard experience.
      cordova.plugins.Keyboard.disableScroll(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
    var push = PushNotification.init({
        android: {
          senderID: "411587591993"
        },
        browser: {
            pushServiceURL: 'http://push.api.phonegap.com/v1/push'
        },
        ios: {
            alert: "true",
            badge: "true",
            sound: "true"
        },
        windows: {}
    });
      push.on('registration', function(data) {
          console.log("Device Token: " + data.registrationId);
          $rootScope.devToken = data.registrationId;
      })
      push.on('notification', function(data) {
          if (data.additionalData.foreground) {
            alert(data.message);
          }
      })
  });
})

Can anyone help me figure out why the push.on('registration') even won't register my device to get me the id? Here is my Xcode console log:

2016-08-19 15:43:27.474 pushNotify[930:236258] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///private/var/mobile/Containers/Data/Application/91498E22-6A53-405A-9497-B0EC644365B2/Library/Cookies/Cookies.binarycookies
2016-08-19 15:43:27.566 pushNotify[930:236258] Apache Cordova native platform version 4.1.0 is starting.
2016-08-19 15:43:27.567 pushNotify[930:236258] Multi-tasking -> Device: YES, App: YES
2016-08-19 15:43:27.622 pushNotify[930:236258] Using UIWebView
2016-08-19 15:43:27.625 pushNotify[930:236258] [CDVTimer][handleopenurl] 0.119984ms
2016-08-19 15:43:27.626 pushNotify[930:236258] [CDVTimer][intentandnavigationfilter] 1.450002ms
2016-08-19 15:43:27.626 pushNotify[930:236258] [CDVTimer][gesturehandler] 0.083029ms
2016-08-19 15:43:27.626 pushNotify[930:236258] CDVPlugin class CDVSplashScreen (pluginName: splashscreen) does not exist.
2016-08-19 15:43:27.627 pushNotify[930:236258] [CDVTimer][splashscreen] 0.093997ms
2016-08-19 15:43:27.627 pushNotify[930:236258] CDVPlugin class CDVStatusBar (pluginName: statusbar) does not exist.
2016-08-19 15:43:27.627 pushNotify[930:236258] [CDVTimer][statusbar] 0.087023ms
2016-08-19 15:43:27.627 pushNotify[930:236258] CDVPlugin class IonicKeyboard (pluginName: keyboard) does not exist.
2016-08-19 15:43:27.627 pushNotify[930:236258] [CDVTimer][keyboard] 0.083983ms
2016-08-19 15:43:27.627 pushNotify[930:236258] [CDVTimer][TotalPluginStartup] 2.694964ms
2016-08-19 15:43:27.761 pushNotify[930:236258] createNotificationChecker
2016-08-19 15:43:27.762 pushNotify[930:236258] not coldstart
2016-08-19 15:43:27.763 pushNotify[930:236258] active
2016-08-19 15:43:27.764 pushNotify[930:236258] PushPlugin skip clear badge
2016-08-19 15:43:28.001 pushNotify[930:236258] Resetting plugins due to page load.
2016-08-19 15:43:28.374 pushNotify[930:236258] Finished load of: file:///var/containers/Bundle/Application/E3454A9E-D203-4335-A64F-602C0AE8C181/pushNotify.app/www/index.html
2016-08-19 15:43:28.650 pushNotify[930:236258] CDVPlugin class CDVDevice (pluginName: Device) does not exist.
2016-08-19 15:43:28.650 pushNotify[930:236258] ERROR: Plugin 'Device' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2016-08-19 15:43:28.651 pushNotify[930:236258] -[CDVCommandQueue executePending] [Line 142] FAILED pluginJSON = ["Device651815033","Device","getDeviceInfo",[]]
2016-08-19 15:43:28.654 pushNotify[930:236258] CDVPlugin class CDVStatusBar (pluginName: StatusBar) does not exist.
2016-08-19 15:43:28.654 pushNotify[930:236258] ERROR: Plugin 'StatusBar' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2016-08-19 15:43:28.654 pushNotify[930:236258] -[CDVCommandQueue executePending] [Line 142] FAILED pluginJSON = ["StatusBar651815034","StatusBar","_ready",[]]

Any help would be appreciated. I cannot figure out why it works on android flawlessly and not at all on iOS. Thanks in advance!


Solution

  • What I had to do was uninstall my platforms and reinstall them. It fixed the iOS error. Everything working properly now.