Skip to content

Gracefully handle missing GoogleService-Info.plist on iOS #178

@yusufkandemir

Description

@yusufkandemir

Is your feature request related to a problem? Please describe.

On Android, if you don't call await PushNotifications.register(); on JS side, the app would still work fine without push notifications.

However, on iOS, FirebaseApp.configure() always gets called. That crashes the app when GoogleService-Info.plist is missing:

override public func load() {
if FirebaseApp.app() == nil {
FirebaseApp.configure()
}

This is not ideal for making the push notification feature optional for some environments, such as for some of the devs on the team.

Describe the solution you'd like

Offer a configuration or an API change to turn off this behavior.

One option could be using the didRegisterForRemoteNotificationsWithDeviceToken hook Capacitor PushNotifications plugin uses, and let the user add the FirebaseApp.configure() there, if possible.

One would be to simply remove FirebaseApp.configure() as the official Capacitor guide makes the user add that call. So, the user would have control over the call and optionally not call it.
https://capacitorjs.com/docs/guides/push-notifications-firebase#add-initialization-code

... and then add the configuration method for Firebase to initialization code to your AppDelegate.swift file, in the application(didFinishLaunchingWithOptions) method.
FirebaseApp.configure()

Describe alternatives you've considered
On Android, you can get away by not calling PushNotifications.register(). But, I couldn't find a workaround or alternative for iOS.

Additional context

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions