Jeet Kapadia
Jeet Kapadia

Reputation: 31

How to use Firebase Push Notification Services without adding GoogleService-Info.plist file in Custom Created Framework Xcode

I have created a custom iOS Framework and I want to use Firebase Cloud Messaging from Push Notifications such that If anyone integrates the Framework in his App then he must be able to receive Push Notifications with minimal configuration.

Also, can I add Push Notifications required code programmatically to avoid using GoogleService-Info.plist?

How can I achieve the above functionality?

Upvotes: 1

Views: 713

Answers (1)

Ahmed Abodeif
Ahmed Abodeif

Reputation: 21

I am trying to do something similar. The main issue here is giving your framework a bundle id and ensuring that it is kept when imported in the app. I have been suffering with firebase complaining about inconsistent bundle ids.

In order to initialise a firebase app programatically you can use the snippet below:

    let manualOptions = FirebaseOptions.init(googleAppID: "", gcmSenderID: "")
    manualOptions.bundleID = ""
    manualOptions.apiKey = ""
    manualOptions.projectID = ""
    manualOptions.clientID = ""
    FirebaseApp.configure(name: "gameballSDK_FirebaseApp", options: manualOptions)

All the data can be obtained from your firebase project GoogleService-Info.plist This code initializes a secondary firebase app. I am not sure if someone has been able to receive push notifications using firebase secondary app. To initialize firebase primary app use the function below:

FirebaseApp.configure(options: <#T##FirebaseOptions#>)

This won't work if the app using your framework is already using firebase for push notifications

Upvotes: 1

Related Questions