capawesome-team / capacitor-firebase

⚡️ Firebase plugins for Capacitor. Supports Android, iOS and the Web.
https://capawesome.io/plugins/firebase/
Apache License 2.0
388 stars 100 forks source link

feat: add support for Notification Service Extension #732

Closed moh4sa closed 1 week ago

moh4sa commented 1 week ago

Plugin(s)

Current problem

currently @capacitor-firebase/messaging does support Notification Service Extension

Preferred solution

add support for "Notification Service Extension"

Alternative options

https://capacitorjs.com/docs/guides/push-notifications-firebase#images-in-push-notifications

Additional context

No response

Before submitting

robingenz commented 1 week ago

I know from https://github.com/capawesome-team/capacitor-firebase/issues/731 that the problem is the Firebase Messaging pod. Have you tried using the same version of the pod that the plugin uses?

Currently this is ~> 10.25, see https://github.com/capawesome-team/capacitor-firebase/blob/1075c9caf328b1acf670f71b199834a3e14ef9f7/packages/messaging/CapacitorFirebaseMessaging.podspec#L16C38-L16C46.

target 'pushextension' do
-  pod 'FirebaseMessaging'
+  pod 'FirebaseMessaging', '~> 10.25'
end
moh4sa commented 1 week ago

@robingenz this is what I got: [capacitor] ✖ update ios - failed! [capacitor] [error] Analyzing dependencies [capacitor] [!] CocoaPods could not find compatible versions for pod "Firebase/Messaging~> 10.25": [capacitor] In Podfile: [capacitor] Firebase/Messaging~> 10.25 [capacitor]
[capacitor] None of your spec sources contain a spec satisfying the dependency: Firebase/Messaging~> 10.25.

robingenz commented 1 week ago

How does your Podfile look?

moh4sa commented 1 week ago
require_relative '../../node_modules/@capacitor/ios/scripts/pods_helpers'

platform :ios, '15.0'
use_frameworks!

# workaround to avoid Xcode caching of Pods that requires
# Product -> Clean Build Folder after new Cordova plugins installed
# Requires CocoaPods 1.6 or newer
install! 'cocoapods', :disable_input_output_paths => true

def capacitor_pods
  pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
  pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
  pod 'CapacitorFirebaseAnalytics', :path => '../../node_modules/@capacitor-firebase/analytics'
  pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app'
  pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics'
  pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard'
  pod 'CapacitorPushNotifications', :path => '../../node_modules/@capacitor/push-notifications'
  pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
end

target 'App' do
  capacitor_pods
  # Add your Pods here
  pod 'Firebase/Messaging' '~> 10.25'
  pod 'CapacitorFirebaseAnalytics/Analytics', :path => '../../node_modules/@capacitor-firebase/analytics'
end

target 'NotificationService' do
  pod 'Firebase/Messaging' '~> 10.25'
end

post_install do |installer|
  assertDeploymentTarget(installer)
end
robingenz commented 1 week ago

You forgot the comma. Please copy the text as I have provided it here.

moh4sa commented 1 week ago

@robingenz I got new error node_modules/@capacitor-firebase/analytics/ios/Plugin/FirebaseAnalytics.swift:4:8 No such module 'FirebaseCore'

robingenz commented 1 week ago

This is another error that has already been solved, see: https://github.com/capawesome-team/capacitor-firebase/issues/622. For this reason, I am closing this issue as resolved.

moh4sa commented 1 week ago

@robingenz Multiple commands produce `'/Users/xx/Library/Developer/Xcode/DerivedData/App-ezouattdyjhpmjfmuuwbpceeevmy/Build/Intermediates.noindex/ArchiveIntermediates/App/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities_Privacy.bundle'

Showing All Messages Target 'GoogleUtilities-54d832b6-GoogleUtilities_Privacy' (project 'Pods') has create directory command with output '/Users/mohdalshehri/Library/Developer/Xcode/DerivedData/App-ezouattdyjhpmjfmuuwbpceeevmy/Build/Intermediates.noindex/ArchiveIntermediates/App/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities_Privacy.bundle'

Showing All Messages Target 'GoogleUtilities-7cacef58-GoogleUtilities_Privacy' (project 'Pods') has create directory command with output '/Users/mohdalshehri/Library/Developer/Xcode/DerivedData/App-ezouattdyjhpmjfmuuwbpceeevmy/Build/Intermediates.noindex/ArchiveIntermediates/App/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities_Privacy.bundle'`

this is the main issue I am facing since #731

robingenz commented 1 week ago

Do you have the full error message? These are just normal log outputs.


The error you mentioned in #731 seems to be a different one:

Target 'GoogleUtilities-7cacef58' (project 'Pods') has create directory command with output '/Users/mohdalshehri/Library/Developer/Xcode/DerivedData/App-ezouattdyjhpmjfmuuwbpceeevmy/Build/Intermediates.noindex/ArchiveIntermediates/App/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework'

moh4sa commented 1 week ago

here is a screenshot of the full error:

Screenshot 2024-10-08 at 11 01 14 AM
robingenz commented 1 week ago

Remove the following code from your Podfile:

target 'pushextension' do
  pod 'FirebaseMessaging', '~> 10.25'
end

Now sync your Capacitor project (npy cap sync) and try it again.

moh4sa commented 1 week ago

@robingenz but this is needed for push notification service extension otherwise the feature it wont work

robingenz commented 1 week ago

Have you tested it? The pod is already added by the plugin itself.

moh4sa commented 1 week ago

yes @robingenz it gives me this error

Screenshot 2024-10-08 at 12 00 21 PM
robingenz commented 1 week ago

You use the Capacitor Firebase Messaging plugin from Capawesome, right? You are NOT using the Capacitor Push Notifications plugin.

moh4sa commented 1 week ago

no Im using the official plugin from capacitor https://capacitorjs.com/docs/guides/push-notifications-firebase#images-in-push-notifications

robingenz commented 1 week ago

As already mentioned, please use the Capacitor Firebase Messaging plugin from Capawesome so that there are no conflicts with the SDK version.

moh4sa commented 1 week ago

I will use it if it supportsNotification Service Extension but as far as I know it doesn't which is why I created this Feature request to migrate to Capacitor Firebase Messaging after it support Notification Service Extension otherwise I can't use @capacitor-firebase do to these conflicts

robingenz commented 1 week ago

The Notification Service Extension should already work with @capacitor-firebase/messaging as this is a feature of the Firebase Messaging SDK (and not the plugin). There are just no docs for it. If you swap the plugins and remove the code block from the Podfile, it should work.

moh4sa commented 1 week ago

@robingenz I've tried it, but it gives me the same error as before.

yes @robingenz it gives me this error Screenshot 2024-10-08 at 12 00 21 PM

robingenz commented 6 days ago

It seems like your project is a little messed up. It's hard for me to help you via GitHub/Chat. The last thing I can offer you is that you book a consulting hour with me (see here) and we look at it together.

moh4sa commented 6 days ago

@robingenz thanks for the support, it appears its a cocoaPods issue I was able to fix after checking this issue