capacitor-community / fcm

Enable Firebase Cloud Messaging for Capacitor apps

Home Page:https://capacitor.ionicframework.com/docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

question: Do we need to edit AppDelegate.swift?

mesqueeb opened this issue · comments

Some things to note about the AppDelegate.swift file:

  • A fresh install of iOS capacitor 3.x ends at line 67.
  • The documentation on @capacitor/push-notifications has lines 69 ~ 79 but without the #if USE_PUSH
  • The example app has a lot of extra code below 79:

https://github.com/capacitor-community/fcm/blob/master/example/ios/App/App/AppDelegate.swift#L81

Questions:

  1. Do we need to manually add all these methods for the FCM plugin to work? (the stuff below line 81)
  2. Do we need to include that #if USE_PUSH or not?

I'm sorry to ask so many questions, but I'm not familiar with Swift : S

  1. no, it's not required
  2. yes, but the #if USE_PUSH is optional, if you plan to implement push you need the whole block, otherwise you can remove it.

just for reference, on Capacitor migration guide they ask to remove the #if statement
I didn't remove in the example app but it's working still

Screen Shot 2021-10-05 at 19 38 37

@stewones thanks for the elaboration!

@stewones In order to get push notifications to work on iOS, I had to add the following to my AppleDelegate.swift: https://d.joshf.xyz/LBSR8X, which is also documented here.

I just wanted to make sure that this was expected (and that there wasn't something I was missing), since I was under the impression that this package made it so that you didn't have to modify any native code. I also don't see this mentioned in the iOS setup (in the README).