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

iOS: Distinguishing between remote push notifications

    Details

      Description

      {html}<div><p><strong><em>Problem</em></strong></p>
      <p>When an app is running and a remote push notification is
      received, the callback passed to
      Ti.Network.registerForPushNotifications is called. This is
      fine.</p>
      <p>When an app is NOT running and a remote push notification is
      received, if the user taps "View" to open the app, the callback is
      also called, but NOTHING is included in the event to indicate that
      this notification was already displayed to the user and the app was
      launched via the "View" button. Thus, the app displays the
      notification that the user has already seen.</p>
      <p>There are three possible cases:</p>
      <ol>
      <li>App just launched (by tapped the action button (named "View" by
      default) in the notification presented by iOS.<br></li>
      <li>App made active (brought from background to foreground, again
      by the action button).<br></li>
      <li>App already running (in foreground).</li>
      </ol>
      <p><strong><em>Suggested Obj-C Fix</em></strong></p>
      <pre>
      <code>FROM:

      // check to see upon registration if we were started with a push
      // notification and if so, go ahead and trigger our callback
      id currentNotification = [[TiApp app] remoteNotification];
      if (currentNotification!=nil && pushNotificationCallback!=nil)
      { id event = [NSDictionary dictionaryWithObject:currentNotification forKey:@"data"]; [self _fireEventToListener:@"remote" withObject:event listener:pushNotificationCallback thisObject:nil]; }

      TO:

      // check to see upon registration if we were started with a push
      // notification and if so, go ahead and trigger our callback
      id currentNotification = [[TiApp app] remoteNotification];
      if (currentNotification!=nil && pushNotificationCallback!=nil)
      { id event = [NSDictionary dictionaryWithObjectsAndKeys:currentNotification, @"data", NUMBOOL(YES), @"firedFromRegister", nil]; [self _fireEventToListener:@"remote" withObject:event listener:pushNotificationCallback thisObject:nil]; }</code>
      </pre>
      <p>See Ticket Reference for more Detail: <a href=
      "http://support.appcelerator.com/tickets/EBJ-28594-463">http://support.appcelerator.com/tickets/EBJ-28594-463</a></p></div>{html}

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                srahim Sabil Rahim
                Reporter:
                aleard Alan Leard
              • Watchers:
                6 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