Uploaded image for project: 'Appcelerator - INBOX'
  1. Appcelerator - INBOX
  2. AC-6015

iOS: Local Notification not triggering "notification" listener when app in foreground but triggering "registerForPushNotifications" callback

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Duplicate
    • Affects Version/s: None
    • Component/s: None
    • Environment:

      Ti SDK 7.4.1 / 7.4.2

      Description

      When adding remote and local notification as below and scheduling a local notification, if the app remains in the foreground the local notification triggers the "registerForPushNotifications" callback and not the "notification" listener. The notifications type is even set as remote, it should be set to local.

      The expected is that the local notification will not trigger the "registerForPushNotifications" callback but the "notification" listener.

      There is also another bug related to the "repeat" variable.

      // START FUNCTION - registerForPush
      function registerForPush() {
      	Ti.Network.registerForPushNotifications({
      		success: deviceTokenSuccess,
      		error: deviceTokenError,
      		callback: receivePush
      	});
                   
          // Remove event listener once registered for push notifications
          Ti.App.iOS.removeEventListener('usernotificationsettings', registerForPush); 
      };
       // END FUNCTION - registerForPush
       
      // ADD Eventlistener to Wait for user settings to be registered before registering for push notifications
      Ti.App.iOS.addEventListener('usernotificationsettings', registerForPush);
       
      // Register notification types to use
      Ti.App.iOS.registerUserNotificationSettings({
      	types: [
      	    Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT,
      	    Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND,
      	    Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE
      	]
      });
       
      // Start Function - deviceTokenSuccess
      function deviceTokenSuccess(e) {
      	Ti.API.info("Register with deviceToken: " + e.deviceToken);   
      };
      // End Function - deviceTokenSuccess
       
      // Start Function - deviceTokenError
      function deviceTokenError(e) {
      	Ti.API.info("Failed to Find Token" + e.error);
      };
      // End Function - deviceTokenError
       
      // START FUNCTION - receivePush for iOS
      function receivePush(e) {		
      	Ti.API.info("Received Push:" + JSON.stringify(e));  		
      };
      // END FUNCTION - receivePush for iOS
       
      Ti.App.iOS.addEventListener('notification', function(e) {
      	Ti.API.info("Received Local push in foreground:" + JSON.stringify(e));  
      });
       
      Ti.App.iOS.addEventListener('localnotificationaction', function(e) {
      	Ti.API.info("Received Local push in background:" + JSON.stringify(e));  
      });
       
      // set scheduled notification
      var notification = Ti.App.iOS.scheduleLocalNotification({        
      	        // Create an ID for the notification 
      	        userInfo: {"type": "localnotification", "id": 1,},
      	        alertBody: "message",
      	        badge: 1,
      	        date: new Date(new Date().getTime() + 10000),
      	        repeat: "monthly", //  ANOTHER BUG << https://jira.appcelerator.org/browse/AC-6013        	        
      });
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                shossain Shak Hossain (Inactive)
                Reporter:
                dieskim David van de Meer
              • Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Git Integration