Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Push Notification causing AppFlow Failure #4570

Closed
beckyhilton opened this issue May 13, 2021 · 8 comments
Closed

bug: Push Notification causing AppFlow Failure #4570

beckyhilton opened this issue May 13, 2021 · 8 comments

Comments

@beckyhilton
Copy link

Bug Report

Capacitor Version

馃拪   Capacitor Doctor  馃拪 

Latest Dependencies:

  @capacitor/cli: 2.4.7
  @capacitor/core: 2.4.7
  @capacitor/android: 2.4.7
  @capacitor/electron: 2.4.7
  @capacitor/ios: 2.4.7

Installed Dependencies:

  @capacitor/cli 2.4.7
  @capacitor/core 2.4.7
  @capacitor/ios 2.4.7
  @capacitor/android 2.4.7
  @capacitor/electron not installed

[success] Android looking great! 馃憣
  Found 6 Capacitor plugins for ios:
    @capacitor-community/firebase-analytics (0.3.0)
    @capacitor-community/native-market (0.1.4)
    call-number (1.0.1)
    cordova-plugin-androidx (2.0.0)
    cordova-plugin-androidx-adapter (1.1.3)
    phonegap-plugin-barcodescanner (8.1.0)
[success] iOS looking great! 馃憣

Platform(s)

iOS

Current Behavior

Build failure in App Flow

ios/App/App/AppDelegate.swift:67:7: cannot find 'InstanceID' in scope

      InstanceID.instanceID().instanceID { (result, error) in
                                                            ^~~~~~~~~~~~

Expected Behavior

Successful App Flow Build

Code Reproduction

I believe this is related to the code provided on this page https://capacitorjs.com/docs/guides/push-notifications-firebase

    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        Messaging.messaging().apnsToken = deviceToken
        InstanceID.instanceID().instanceID { (result, error) in
            if let error = error {
                NotificationCenter.default.post(name: Notification.Name(CAPNotifications.DidFailToRegisterForRemoteNotificationsWithError.name()), object: error)
            } else if let result = result {
                NotificationCenter.default.post(name: Notification.Name(CAPNotifications.DidRegisterForRemoteNotificationsWithDeviceToken.name()), object: result.token)
            }
        }
    }

Other Technical Details

npm --version output: 7.6.0

node --version output: v12.19.0

pod --version output (iOS issues only): 1.9.3

Additional Context

In XCode I see this error message

'InstanceID' is deprecated: FIRInstanceID is deprecated, please use FIRInstallations for installation identifier handling and use FIRMessaging for FCM registration token handling.

And in the firebase release notes I saw this "The deprecated Firebase InstanceID has been removed. Use Firebase Installations to manage app instance and use Firebase Messaging to manage FCM registration token instead" which I thought might be the cause

https://firebase.google.com/support/release-notes/ios

@beckyhilton
Copy link
Author

I think this might be a partial solution but my swift isn't very good so its not handling the error like the other one was.

NotificationCenter.default.post(name: Notification.Name(CAPNotifications.DidRegisterForRemoteNotificationsWithDeviceToken.name()), object: Messaging.token(completion:))

@beckyhilton beckyhilton changed the title bug: bug: Push Notification causing AppFlow Failure May 14, 2021
@samvimes01
Copy link

samvimes01 commented May 14, 2021

It fails even on import FirebaseInstanceID
I assume it happened after the Firebase core was upgraded to v8 and some deprecated items were removed.
As a temporary fix, versions of the firebase core and messaging could be hardcoded to the latest that was working without errors (7.11.0)
ios/App/Podfile:

target 'App' do
  capacitor_pods
  # Add your Pods here
  pod 'FirebaseCore', '7.11.0' // add the version explicitly
  pod 'Firebase/Messaging', '7.11.0'
end

@SyFlo
Copy link

SyFlo commented May 18, 2021

same problem here. any solutions in sight?

@beckyhilton
Copy link
Author

@SyFlo switching to the v7.11.0 seems to be working for me for now as a work around.

@SyFlo
Copy link

SyFlo commented May 20, 2021

@beckyhilton yes, I'm also using v7.11.0 as a workaround now

@jcesarmobile
Copy link
Member

If you are using capacitor 2, we recommend fixing the FirebaseCore and Firebase/Messaging versions to 7.11.0

  pod 'FirebaseCore', '7.11.0'
  pod 'Firebase/Messaging', '7.11.0'

If using capacitor 3, follow this guide
https://capacitorjs.com/docs/guides/push-notifications-firebase

If you want to use FirebaseCore and Firebase/Messaging 8, you can still check the capacitor 3 guide, but note that the capacitor notifications to send the token/error to the js side changed the name, so you need to use the old names instead of the names on that guide

@beckyhilton
Copy link
Author

@jcesarmobile Thanks!

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 11, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants