capacitor-community / capacitor-community/fcm

Gracefully handle missing GoogleService-Info.plist on iOS

Open
#178 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
272
Forks
96
PR merge metrics
No merged PRs in 30d

Description

**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:
https://github.com/capacitor-community/fcm/blob/fab6ec2310a6721513f0efc67cc75e8da1636729/ios/Plugin/Plugin.swift#L19-L22

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](https://github.com/user-attachments/assets/6c5b1504-bd24-434c-9cac-39b46d00e092)

Contributor guide

Open the contributing guide

Research direction

Start with ios/Plugin/Plugin.swift at the FirebaseApp.configure() call and compare it with the Capacitor PushNotifications registration hook and the AppDelegate application(didFinishLaunchingWithOptions) guidance linked in the issue. Determine a supported way to avoid configuration when GoogleService-Info.plist is absent, then verify that iOS apps without Firebase configuration no longer crash while configured apps still initialize Firebase.

Written by the indexing model from the issue text.

Assessment

Tech stack
firebase, ios, swift
Domain
mobile
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.