{"action":"created","issue":{"url":"https://api.github.com/repos/phonegap/phonegap-plugin-push/issues/2206","repository_url":"https://api.github.com/repos/phonegap/phonegap-plugin-push","labels_url":"https://api.github.com/repos/phonegap/phonegap-plugin-push/issues/2206/labels{/name}","comments_url":"https://api.github.com/repos/phonegap/phonegap-plugin-push/issues/2206/comments","events_url":"https://api.github.com/repos/phonegap/phonegap-plugin-push/issues/2206/events","html_url":"https://github.com/phonegap/phonegap-plugin-push/issues/2206","id":297989693,"number":2206,"title":"In ios app, unable to Receive a Notification when app is in foreground","user":{"login":"Prashant454","id":17173246,"avatar_url":"https://avatars3.githubusercontent.com/u/17173246?v=4","gravatar_id":"","url":"https://api.github.com/users/Prashant454","html_url":"https://github.com/Prashant454","followers_url":"https://api.github.com/users/Prashant454/followers","following_url":"https://api.github.com/users/Prashant454/following{/other_user}","gists_url":"https://api.github.com/users/Prashant454/gists{/gist_id}","starred_url":"https://api.github.com/users/Prashant454/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Prashant454/subscriptions","organizations_url":"https://api.github.com/users/Prashant454/orgs","repos_url":"https://api.github.com/users/Prashant454/repos","events_url":"https://api.github.com/users/Prashant454/events{/privacy}","received_events_url":"https://api.github.com/users/Prashant454/received_events","type":"User","site_admin":false},"labels":[{"id":307723293,"url":"https://api.github.com/repos/phonegap/phonegap-plugin-push/labels/ios","name":"ios","color":"BFD4F2","default":false},{"id":196374009,"url":"https://api.github.com/repos/phonegap/phonegap-plugin-push/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-02-17T08:34:54Z","updated_at":"2018-02-21T10:58:23Z","closed_at":null,"author_association":"NONE","body":"### Expected Behaviour\r\nShould Receive a Notification when app is in foreground\r\n### Actual Behaviour\r\ndoes nothing not even a log is printed\r\n### Reproduce Scenario (including but not limited to)\r\n\r\n#### Steps to Reproduce \r\nopen app and try to send fcm \r\n#### Platform and Version (eg. Android 5.0 or iOS 9.2.1)\r\nios 9.0\r\n#### Cordova CLI version and cordova platform version\r\n\r\n    cordova --version                                    7.0.1\r\n    cordova platform version ios                      ios 4.4.0\r\n\r\n#### Plugin version\r\n\r\n    cordova plugin version | grep phonegap-plugin-push   # e.g. 1.5.3\r\n\r\n#### Sample Push Data Payload\r\n{\r\n\"title\": \"New Update Available\",\r\n\"body\": \"EventsPage\",\r\n\"sound\": \"default\",\r\n\"image\": \"www/assets/img/icon.png\",\r\n\"style\": \"picture\",\r\n\"picture\": \"http://im.rediff.com/news/2014/aug/25bmc.jpg\",\r\n\"page\": \"EventsPage\",\r\n\"image-type\": \"circle\",\r\n\"content-available\": 1,\r\n\"force-start\": 1,\r\n\"summaryText\": \"EventsPage\",\r\n\"click_action\": \"FCM_PLUGIN_ACTIVITY\",\r\n\"notId\": 7248,\r\n\"surveyID\": \"ewtawgreg-gragrag-rgarhthgbad\"\r\n}\r\n#### Sample Code that illustrates the problem\r\n\r\n```\r\npushObject.on('notification').subscribe((notification: any) => {\r\n\r\n        //working\r\n        // this.localNotifications.schedule({\r\n        //   id: 1,\r\n        //   text: 'Single ILocalNotification',\r\n        //   sound: this.platform.is('android')? 'file://sound.mp3': 'file://beep.caf',\r\n        //   data: { secret: 'dd' }\r\n        // });\r\n\r\n        // this.events.publish('notification:arrived', {count:1,page:notification.additionalData.page});\r\n        console.log('1noti' + JSON.stringify(notification));\r\n\r\n        if(MyApp.notiID!=notification.additionalData.notId) {\r\n          this.events.publish('notification:arrived', {count:1,page:notification.additionalData.page});\r\n          console.log('2noti' + notification.additionalData.notId);\r\n          MyApp.notiID=notification.additionalData.notId;\r\n\r\n          var noti1 = {\r\n            title: notification.title,\r\n            description: notification.message,\r\n            notificationType: notification.additionalData.notificationType,\r\n            page: notification.additionalData.page,\r\n            data: notification.additionalData,\r\n            photoPath: notification.additionalData.picture,\r\n            updatedOn: new Date(),\r\n            viewed: 1,\r\n            notID:0\r\n          };\r\n          this.storage.get('Notifications').then((data) => {\r\n            if (data != null) {\r\n              this.Notifications = data;\r\n              noti1['notID'] = data.length + 1;\r\n              this.Notifications.push(noti1);\r\n              this.storage.set('Notifications', this.Notifications);\r\n            }\r\n            else{\r\n              this.Notifications=[];\r\n              noti1['notID'] = 1;\r\n              this.Notifications.push(noti1);\r\n              this.storage.set('Notifications', this.Notifications);\r\n            }\r\n\r\n          });\r\n        }\r\n\r\n        if (notification.additionalData.foreground == true)\r\n        {\r\n\r\n          let alert = this.alertCtrl.create({\r\n            title: 'New Notification',\r\n            message: notification.title,\r\n            buttons: [\r\n              {\r\n                text: 'Close',\r\n                role: 'cancel',\r\n                handler: () => {\r\n                  // console.log('Cancel clicked');\r\n                }\r\n              },\r\n              {\r\n                text: 'View',\r\n                handler: () => {\r\n                  // user tapped on notification\r\n                  // alert('tapped');\r\n                  this.app.getActiveNav().push(notification.additionalData.page,{data:notification.additionalData});\r\n                  this.storage.set('curNotification', '');\r\n                }\r\n\r\n              }\r\n            ]\r\n          });\r\n          alert.present();\r\n\r\n        }\r\n\r\n        else if (notification.additionalData.foreground == false &&\r\n          notification.additionalData.coldstart == true){\r\n          this.storage.set('curNotification',notification.additionalData);\r\n        }\r\n\r\n      }\r\n```\r\n\r\n#### Logs taken while reproducing problem\r\nEven if this log says notification received but wont call On('notification') event\r\n2018-02-17 15:44:43.292 Credai Maharashtra[721:121911] didReceiveNotification with fetchCompletionHandler\r\n2018-02-17 15:44:43.292 Credai Maharashtra[721:121911] app active\r\n2018-02-17 15:44:43.293 Credai Maharashtra[721:121911] Notification received\r\n2018-02-17 15:44:43.293 Credai Maharashtra[721:121911] Push Plugin key: badge\r\n2018-02-17 15:44:43.293 Credai Maharashtra[721:121911] Push Plugin key: sound\r\n2018-02-17 15:44:43.293 Credai Maharashtra[721:121911] Push Plugin key: alert"},"comment":{"url":"https://api.github.com/repos/phonegap/phonegap-plugin-push/issues/comments/367290155","html_url":"https://github.com/phonegap/phonegap-plugin-push/issues/2206#issuecomment-367290155","issue_url":"https://api.github.com/repos/phonegap/phonegap-plugin-push/issues/2206","id":367290155,"user":{"login":"Prashant454","id":17173246,"avatar_url":"https://avatars3.githubusercontent.com/u/17173246?v=4","gravatar_id":"","url":"https://api.github.com/users/Prashant454","html_url":"https://github.com/Prashant454","followers_url":"https://api.github.com/users/Prashant454/followers","following_url":"https://api.github.com/users/Prashant454/following{/other_user}","gists_url":"https://api.github.com/users/Prashant454/gists{/gist_id}","starred_url":"https://api.github.com/users/Prashant454/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Prashant454/subscriptions","organizations_url":"https://api.github.com/users/Prashant454/orgs","repos_url":"https://api.github.com/users/Prashant454/repos","events_url":"https://api.github.com/users/Prashant454/events{/privacy}","received_events_url":"https://api.github.com/users/Prashant454/received_events","type":"User","site_admin":false},"created_at":"2018-02-21T10:58:23Z","updated_at":"2018-02-21T10:58:23Z","author_association":"NONE","body":"I have tried with this payload not working in foreground. In background works fine\r\n\r\n{\r\n    \"registration_ids\": [\"my device id\"],\r\n    \"notification\": {\r\n\"title\": \"New Update Available\",\r\n\"body\": \"EventsPage\",\r\n    }\r\n    \"data\": {\r\n\"notId\": 7248,\r\n\"surveyID\": \"ewtawgreg-gragrag-rgarhthgbad\"\r\n    }\r\n}"}}
{"actor":{"display_login":"Prashant454"}}