{"action":"created","issue":{"url":"https://api.github.com/repos/katzer/cordova-plugin-local-notifications/issues/772","labels_url":"https://api.github.com/repos/katzer/cordova-plugin-local-notifications/issues/772/labels{/name}","comments_url":"https://api.github.com/repos/katzer/cordova-plugin-local-notifications/issues/772/comments","events_url":"https://api.github.com/repos/katzer/cordova-plugin-local-notifications/issues/772/events","html_url":"https://github.com/katzer/cordova-plugin-local-notifications/issues/772","id":120364807,"number":772,"title":"What should happen on iOS when initial notification displayed in drawer?","user":{"login":"rwillett","id":668923,"avatar_url":"https://avatars.githubusercontent.com/u/668923?v=3","gravatar_id":"","url":"https://api.github.com/users/rwillett","html_url":"https://github.com/rwillett","followers_url":"https://api.github.com/users/rwillett/followers","following_url":"https://api.github.com/users/rwillett/following{/other_user}","gists_url":"https://api.github.com/users/rwillett/gists{/gist_id}","starred_url":"https://api.github.com/users/rwillett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rwillett/subscriptions","organizations_url":"https://api.github.com/users/rwillett/orgs","repos_url":"https://api.github.com/users/rwillett/repos","events_url":"https://api.github.com/users/rwillett/events{/privacy}","received_events_url":"https://api.github.com/users/rwillett/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/katzer/cordova-plugin-local-notifications/labels/ios","name":"ios","color":"bfd4f2"}],"state":"closed","locked":false,"assignee":{"login":"katzer","id":2039384,"avatar_url":"https://avatars.githubusercontent.com/u/2039384?v=3","gravatar_id":"","url":"https://api.github.com/users/katzer","html_url":"https://github.com/katzer","followers_url":"https://api.github.com/users/katzer/followers","following_url":"https://api.github.com/users/katzer/following{/other_user}","gists_url":"https://api.github.com/users/katzer/gists{/gist_id}","starred_url":"https://api.github.com/users/katzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/katzer/subscriptions","organizations_url":"https://api.github.com/users/katzer/orgs","repos_url":"https://api.github.com/users/katzer/repos","events_url":"https://api.github.com/users/katzer/events{/privacy}","received_events_url":"https://api.github.com/users/katzer/received_events","type":"User","site_admin":false},"milestone":null,"comments":7,"created_at":"2015-12-04T09:34:02Z","updated_at":"2016-01-02T12:46:08Z","closed_at":"2016-01-02T10:22:39Z","body":"Hi,\r\n\r\nWe're trying to work out if this is a bug or a feature. We're not sure and we can't find any docs to tell us. We think we have our app and this plugin working well but for one odd edge case and can't work out if its a problem of not. This is all iOS V8, de.appplant.cordova.plugin.local-notification 0.8.2\r\n\r\nIf I explain the steps it might be help, just to be clear we're not looking for code or debugging, just some useful insight. We have this stuff working, but its odd for one little bit :)\r\n\r\n1. We put our app into the background.  - **All working**\r\n\r\n2. We send data to our app via a silent notification using the content-available: 1 flag - **All working**\r\n\r\n3. We capture the silent notification in our app - **All working**\r\n\r\n4. We go back to our server and download some more data to process - **All working**\r\n\r\n5. We process the data we have recovered from the server and generate 2-3 local notifications to display to the user. This simulates the way push notifications work but gives us far, far more control about how we handle and display them, The local-notifications we generate are not scheduled but are simple text messages with a unique piece of data attached so we know how to handle them when the user selects them from the notification drawer. We send the notifications down as an array in one go, rather than as a series of cordova.plugins.notification.local.schedule calls. We read on this site that doing them one after the other is slow. We attach code to show this - **All working**\r\n\r\n ````\r\n                for (var key in notificationQueue)\r\n                {\r\n                    if (debugGetNotificationsFromServerSuccess)\r\n                        ConsoleLog(\"LocalNotification: \" + key + \" \" + notificationQueue[key].message);\r\n\r\n                    switch (whatAmI) {\r\n                        case \"ios_app\":\r\n                        case \"ios_simulator\":\r\n                        default:\r\n                            notification = {id: key ,\r\n                                            text: notificationQueue[key].message};\r\n                            break;\r\n\t\t                case \"android_app\":\r\n                        case \"android_simulator\":\r\n                            notification = {id: key ,\r\n                                            text: notificationQueue[key].message ,\r\n                                            smallIcon: \"file://notification.png\"};\r\n                            break;\r\n                    }\r\n\r\n                    tmpArray.push(notification);\r\n                }\r\n\r\n                cordova.plugins.notification.local.schedule(tmpArray);\r\n\r\n                cordova.plugins.notification.local.on(\"click\", function (notification , state) {\r\n                    var debug = 1;\r\n\r\n                    if (debug)\r\n                    {\r\n                        ConsoleLog(\"Local Notifications Click: notification=\" + JSON.stringify(notification));\r\n                        ConsoleLog(\"Local Notifications Click: state=\" + JSON.stringify(state));\r\n                    }\r\n\r\n                    // Need to remove notification.id from notificationQueue\r\n                    RemoveNotificationFromQueue(notification.id);\r\n                    $rootScope.$broadcast('new_notification' , { Disruption_Id: notification.id });\r\n                }, this)\r\n ````\r\n\r\n6. When we send the local notification two things happen, a small window pops down from the top of the iOS display showing the contents of each notification we have sent using cordova.plugins.notification.local.schedule, so if we send 3 notifications, we get three little windows that display and then hide. These pop down for a few tenths of seconds only **This is the bit that we don't quite understand, see point 8 for more information**\r\n\r\n7. The local notification is then displayed in the notification drawer along with all other notifications. We can click on the notification in this drawer and our app starts up and displays the right information. **All Working**\r\n\r\n8. if we quickly click on the notification that pops down from the top of the display, we get sent back to our app as we expect, BUT we do not get the click event we get if we had clicked the notification in the main Notification Drawer. We have to be quick as the little pop down only lasts a few tenths of seconds. This means we go back to the main screen in our app and we don't go to the screen we need as the click event hasn't fired. Is there another event we should be looking for JUST when that tiny pull down notification occurs or is the iOS behaviour just to open the app up? We would have thought that clicking on that pop down should be treated as the same way as other notifications. We also thought that it might be a timing issue and that the local-notifications aren't quite ready yet.\r\n\r\nEverything else is working well, so we're puzzled by the behaviour here. Any insights on this gratefully received.\r\n\r\nThanks\r\n\r\nRob"},"comment":{"url":"https://api.github.com/repos/katzer/cordova-plugin-local-notifications/issues/comments/168388552","html_url":"https://github.com/katzer/cordova-plugin-local-notifications/issues/772#issuecomment-168388552","issue_url":"https://api.github.com/repos/katzer/cordova-plugin-local-notifications/issues/772","id":168388552,"user":{"login":"rwillett","id":668923,"avatar_url":"https://avatars.githubusercontent.com/u/668923?v=3","gravatar_id":"","url":"https://api.github.com/users/rwillett","html_url":"https://github.com/rwillett","followers_url":"https://api.github.com/users/rwillett/followers","following_url":"https://api.github.com/users/rwillett/following{/other_user}","gists_url":"https://api.github.com/users/rwillett/gists{/gist_id}","starred_url":"https://api.github.com/users/rwillett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rwillett/subscriptions","organizations_url":"https://api.github.com/users/rwillett/orgs","repos_url":"https://api.github.com/users/rwillett/repos","events_url":"https://api.github.com/users/rwillett/events{/privacy}","received_events_url":"https://api.github.com/users/rwillett/received_events","type":"User","site_admin":false},"created_at":"2016-01-02T12:46:08Z","updated_at":"2016-01-02T12:46:08Z","body":"@derDeno \r\n\r\nYes we know. We've implemented Background fetch (https://github.com/christocracy/cordova-plugin-background-fetch) and are exploring what it can (and can't do).\r\n\r\nOne thing we have found with background fetch is that we cannot get Angular $HTTP Posts and Gets to work from inside the background fetch. We can get raw open's to work but nothing more high level. \r\n\r\n```\r\n           xmlhttp.open(\"GET\" , url , true);\r\n\r\n            xmlhttp.onreadystatechange = function() {\r\n\t\t// State 0 is \"request not initialized\"\r\n                // State 1 is \"server connection established\"\r\n                // State 2 is \"request received\"\r\n                // State 3 is \"processing request\"\r\n                // State 4 is \"request finished and response is ready\"\r\n```\r\n\r\nThe background fetch docs talk about jQuery which we are reluctant to use (but may have to). This a pain as we have to rework our existing code if we want to do a background fetch from a server. The upside is that once you have done the background fetch, it *appears* that the app more back to the background from suspended mode for a few minutes more. We still need to confirm this and it may change under different versions of IOS as well.\r\n\r\nI'd be interested in what you have done with background fetch to see if you have the same issues.\r\n\r\nRob"}}