{ "id": "64160", "key": "TIMOB-3528", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "14162", "description": "Release 3.1.0", "name": "Release 3.1.0", "archived": true, "released": true, "releaseDate": "2013-04-16" }, { "id": "15272", "description": "2013 Sprint 04 API", "name": "2013 Sprint 04 API", "archived": true, "released": true, "releaseDate": "2013-02-25" }, { "id": "14814", "description": "2013 Sprint 04", "name": "2013 Sprint 04", "archived": true, "released": true, "releaseDate": "2013-02-25" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2013-02-13T23:55:38.000+0000", "created": "2011-04-15T03:46:20.000+0000", "priority": { "name": "Trivial", "id": "5" }, "labels": [ "CLA", "defect", "ios", "notifications", "push", "rplist" ], "versions": [], "issuelinks": [ { "id": "24474", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "81126", "key": "TIMOB-5437", "fields": { "summary": "iOS: Expose applicationState property of UIApplication Class", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-21T18:25:44.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{html}

Problem

\r\n

When an app is running and a remote push notification is\r\nreceived, the callback passed to\r\nTi.Network.registerForPushNotifications is called. This is\r\nfine.

\r\n

When an app is NOT running and a remote push notification is\r\nreceived, if the user taps \"View\" to open the app, the callback is\r\nalso called, but NOTHING is included in the event to indicate that\r\nthis notification was already displayed to the user and the app was\r\nlaunched via the \"View\" button. Thus, the app displays the\r\nnotification that the user has already seen.

\r\n

There are three possible cases:

\r\n
    \r\n
  1. App just launched (by tapped the action button (named \"View\" by\r\ndefault) in the notification presented by iOS.
  2. \r\n
  3. App made active (brought from background to foreground, again\r\nby the action button).
  4. \r\n
  5. App already running (in foreground).
  6. \r\n
\r\n

Suggested Obj-C Fix

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

See Ticket Reference for more Detail: http://support.appcelerator.com/tickets/EBJ-28594-463

{html}", "attachment": [], "flagged": false, "summary": "iOS: Distinguishing between remote push notifications ", "creator": { "name": "aleard", "key": "aleard", "displayName": "Alan Leard", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "aleard", "key": "aleard", "displayName": "Alan Leard", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "233631", "author": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Not contesting this would be a cute feature request, but I do have to point out a few things:\n\nThe property name is confusing. There is no 'register' per se, one registers with the servers, but that happens regardless of the notification being fired while the application was in the foreground or background. Perhaps a better name for the property might be 'inBackground'.\n\nAlso, note that the different native codepaths depend on if the app was resident in memory. In other words, if the app is backgrounded and then relaunched, the logic suggested would falsely report the application was not in the background due to it not having been unloaded from memory.\n\nFinally, the reason for the request worries me. Applications should not show dialog boxes due to push or local notifications, they should only silently update what's needed. There is a reason that push notifications went from feature to throttled feature to throttled feature that can be disabled.\n\nThe author of the ticket should reconsider his UI regarding notifications, regardless of when this issue is resolved.", "updateAuthor": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-01-08T16:31:35.000+0000", "updated": "2013-01-08T16:31:35.000+0000" }, { "id": "238473", "author": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Fixed by PR: https://github.com/appcelerator/titanium_mobile/pull/3869\nIntroduced new arg to the remote event fired in response to push notification. \n\nFor testing instructions check PR ", "updateAuthor": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-02-13T23:26:12.000+0000", "updated": "2013-02-13T23:26:12.000+0000" }, { "id": "414268", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as fixed.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-21T18:25:44.000+0000", "updated": "2017-03-21T18:25:44.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }