{"action":"created","issue":{"url":"https://api.github.com/repos/ionic-team/capacitor/issues/954","repository_url":"https://api.github.com/repos/ionic-team/capacitor","labels_url":"https://api.github.com/repos/ionic-team/capacitor/issues/954/labels{/name}","comments_url":"https://api.github.com/repos/ionic-team/capacitor/issues/954/comments","events_url":"https://api.github.com/repos/ionic-team/capacitor/issues/954/events","html_url":"https://github.com/ionic-team/capacitor/issues/954","id":377199922,"node_id":"MDU6SXNzdWUzNzcxOTk5MjI=","number":954,"title":"PushNotifications capacitor plugin with FCM on IOS","user":{"login":"HuguesRousseau","id":37377292,"node_id":"MDQ6VXNlcjM3Mzc3Mjky","avatar_url":"https://avatars1.githubusercontent.com/u/37377292?v=4","gravatar_id":"","url":"https://api.github.com/users/HuguesRousseau","html_url":"https://github.com/HuguesRousseau","followers_url":"https://api.github.com/users/HuguesRousseau/followers","following_url":"https://api.github.com/users/HuguesRousseau/following{/other_user}","gists_url":"https://api.github.com/users/HuguesRousseau/gists{/gist_id}","starred_url":"https://api.github.com/users/HuguesRousseau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HuguesRousseau/subscriptions","organizations_url":"https://api.github.com/users/HuguesRousseau/orgs","repos_url":"https://api.github.com/users/HuguesRousseau/repos","events_url":"https://api.github.com/users/HuguesRousseau/events{/privacy}","received_events_url":"https://api.github.com/users/HuguesRousseau/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-04T22:03:59Z","updated_at":"2018-12-11T20:18:20Z","closed_at":null,"author_association":"NONE","body":"Hi. I was able to have the FirebaseCloudMessaging (FCM) integrated on IOS using the @capacitor/ios module, but with some minor modifications, that I wish to share, and get validated. The context is an Angular 6 app built for IOS using ionic capacitor:\r\n1-PushNotifications.swift: will receive the device token for FCM prior to any listener be registered from the Angular app, so in order to let the Angular app know of a new token, I saved it in the CAPPushNotificationsPlugin class, when didRegisterForRemoteNotificationsWithDeviceToken gets called (the token is received as String so that needs to be handled too), and fired the registration event of the said token upon registration. Of course, that means the caller of addListener must call register last (after adding the listeners);\r\n2-CAPUNUserNotificationCenterDelegate.swift: At the end of the userNotificationCenter implementation (willPresent), I replaced the calls to completionHandler with simply: completionHandler([]). The reason is that this function will be called if the app is active and in the foreground, so the listeners that registered for pushNotificationReceived will handle it in-app, so merely refrain from having the native notification be played;\r\n3-AppDelegate.swift: I replaced this file with the one provided by Firebase, with some modifications: I added the import Capacitor, and in the MessagingDelegate I setup the post to CAP instead of FCMToken (NotificationCenter.default.post(name: Notification.Name(CAPNotifications.DidRegisterForRemoteNotificationsWithDeviceToken.name()), object: fcmToken))\r\nThese changes allow to use Firebase tokens on IOS using capacitor on an Angular app, let the latter push the token to a server, and allow for no notifications to be displayed natively if the ios app is active and in the foreground. I do not know of a better way yet. If this is a good way, I wish ionic will integrate it officially so FCM can be used out-of-the-box for multiple platforms, including ios, with an Angular app.\r\nKind regards."},"comment":{"url":"https://api.github.com/repos/ionic-team/capacitor/issues/comments/446347135","html_url":"https://github.com/ionic-team/capacitor/issues/954#issuecomment-446347135","issue_url":"https://api.github.com/repos/ionic-team/capacitor/issues/954","id":446347135,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NjM0NzEzNQ==","user":{"login":"HuguesRousseau","id":37377292,"node_id":"MDQ6VXNlcjM3Mzc3Mjky","avatar_url":"https://avatars1.githubusercontent.com/u/37377292?v=4","gravatar_id":"","url":"https://api.github.com/users/HuguesRousseau","html_url":"https://github.com/HuguesRousseau","followers_url":"https://api.github.com/users/HuguesRousseau/followers","following_url":"https://api.github.com/users/HuguesRousseau/following{/other_user}","gists_url":"https://api.github.com/users/HuguesRousseau/gists{/gist_id}","starred_url":"https://api.github.com/users/HuguesRousseau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HuguesRousseau/subscriptions","organizations_url":"https://api.github.com/users/HuguesRousseau/orgs","repos_url":"https://api.github.com/users/HuguesRousseau/repos","events_url":"https://api.github.com/users/HuguesRousseau/events{/privacy}","received_events_url":"https://api.github.com/users/HuguesRousseau/received_events","type":"User","site_admin":false},"created_at":"2018-12-11T20:18:20Z","updated_at":"2018-12-11T20:18:20Z","author_association":"NONE","body":"@zsoflin Hi. I posted this code modification suggestion in capacitor's slack channel. The thing is that there are some modifications in the capacitor swift plugins to support this, so either we publish a new plugin specialized for fcm, or capacitor integrates it. But I am reluctant to merely publish capacitor changes for others to use, as it should be scoped for discussion purposes only. Can you specify where are the problems you are experiencing?"}}
{"actor":{"display_login":"HuguesRousseau"}}