Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-18182

iOS: Distinguish foreground vs. background in Local Notification

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: Release 3.4.0, Release 3.4.1
    • Fix Version/s: Release 6.2.0
    • Component/s: iOS
    • Labels:
    • Environment:

      SDK 3.3.0, iOS 7

      Description

      Right now there is no way to determine whether a local notification is received when the app is in the foreground or in the background.

      Here is a sample:

      var notification = Ti.App.iOS.scheduleLocalNotification({
          alertAction: 'Check',
          alertBody: 'This is a test',
          date: new Date(new Date().getTime() + 3000)
      });
       
      Ti.App.iOS.addEventListener('notification', function(e) {
          Ti.API.info(JSON.stringify(e));
          notification.cancel();
      });
      

      The passed-through event object is the same for both situations. However, with remote notification you have such ability: http://docs.appcelerator.com/titanium/latest/#!/api/PushNotificationData-property-inBackground

      From Apple's docs, both remote and local notifications are handled similarly. You'll be able to tell whether a local notification is received in the foreground or the background if coding in Objective-C, but not in Titanium.

      This is important since actions taken may need to be different accordingly. E.g. When in the foreground you might just want to display a notification, but not to interrupt what users are doing. When in the background, and users click the notification to launch/resume the app, you want to take the users directly to the action.

      Thanks.

        Attachments

          Activity

            People

            • Assignee:
              hknoechel Hans Knöchel
              Reporter:
              shawnlan Shawn Lan
              Reviewer:
              Vijay Singh
            • Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Source Code