Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications don't work on iOS 10.2 #1205

Closed
apfelstyle opened this issue Feb 4, 2017 · 4 comments
Closed

Notifications don't work on iOS 10.2 #1205

apfelstyle opened this issue Feb 4, 2017 · 4 comments

Comments

@apfelstyle
Copy link

apfelstyle commented Feb 4, 2017

Your Environment

Plugin version: de.appplant.cordova.plugin.local-notification 0.8.5-dev "LocalNotification" (#ios10)
Platform: iOS
OS version: 10.2
Device manufacturer / model: iPhone 7 XCode emulator
Cordova version (cordova -v): 6.4.0
Cordova platform version (cordova platform ls):
Plugin config

Expected Behavior

should fire a notification on iOS or ask for permission.

Actual Behavior

Does not ask for permission and does not fire any notification. Once I got it to ask for permission but after a reset of the simulator it's not working anymore.

What were you trying to do?

There is a controller with $cordovaLocalNotification, $ionicPlatform and $scope

There are 3 buttons to get

  • The permission state
  • To ask for permission
  • To fire a notification
    <button class="button button-full button-positive" ng-click="checkRegister()">
      CheckRegisterStatus
    </button>
    <button class="button button-full button-positive" ng-click="register()">
      Register
    </button>
    <button class="button button-full button-positive" ng-click="fireNoti()">
      Fire Notification
    </button>

Button 1:

      $scope.checkRegister = function() {

        $cordovaLocalNotification.hasPermission(function (granted) {
            console.log('Permission has been granted: ' + granted);
        });
      }
      $scope.register = function(){
        console.log("register");
        $cordovaLocalNotification.registerPermission(function (granted) {
            console.log('Permission has been granted: ' + granted);

        });
      }
       $scope.fireNoti = function(){
        console.log("fire1");
        var now             = new Date().getTime(),
         _5_sec_from_now = new Date(now + 5*1000);

          $cordovaLocalNotification.schedule({
              title: 'Hello World!',
              text: 'Hello World!',
              at: _5_sec_from_now
          }).then(function (result) {
              console.log("fire2");
          });
      }

Android is working perfect! The Notification is fires and everything works flawless.

iOS does not even ask for permission. This is the log XCode shows:

2017-02-04 21:38:37.526 L[17667:705269] fire1
2017-02-04 21:38:38.847 L[17667:705269] register
2017-02-04 21:38:39.589 L[17667:705269] checkRegister

EDIT:

I even tried this with a ionic v2 with the native implementation of local notifications (which is v0.8.4), but even these doesn't work on iOS 10.2 :(

@rwillett
Copy link
Collaborator

rwillett commented Feb 5, 2017

Where is the code that outputs checkRegister?

It looks like you have not given permission for notifications. What are your settings in the Settings panel?

I know that this code works with XCode 10.2 simulator as issue #1192 shows our code working in the Xcode 10.2 simulator :)

Rob

@apfelstyle
Copy link
Author

Founds the issue after better debugging. There was something wrong with the plugin and cordova. The plugin wasn't installed correctly.

After running the iOS build with ionic emulate ios -lc this error showed up:+

14 917372 error Error: undefined is not an object (evaluating 'n.cordova.plugins.notification.local')

the local-notifications.js was missing. So reinstalled the plugin and now its working. Strange that it worked on Android but not on iOS seems like just the iOS installation failed.

The error in my ionic v2 project was something with my code. Now its working there too! Thank you Rob

@rwillett
Copy link
Collaborator

rwillett commented Feb 5, 2017

Thats good to know. It could be how you installed the plugins.

I would have expected an error in Xcode though. We virtually never use the simulator as it doesn't support

  1. Push notifications.
  2. Decent GPS tracking (or any sort of user defined tracking).
  3. Timeouts work differently.

Be very careful with emulation as your code WILL work differently on a real iPhone.

Rob

@mahesh-vi
Copy link

  • Please give solution for iOS 10.2 issue.
  • That issue i am face same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants