Closed benclayton98 closed 7 months ago
Ooh, should also have added to the docs to select objective-c where it says 'language'
Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
Is it possible to use swift instead of Objective-C @helenaford ? We already use NotificationService but with Swift
Is it possible to use swift instead of Objective-C @helenaford ? We already use NotificationService but with Swift
Yes, instead of #import "NotifeeExtensionHelper.h":
import RNNotifeeCore
Instead of
+ [NotifeeExtensionHelper populateNotificationContent:request
withContent: self.bestAttemptContent
withContentHandler:contentHandler];
Use
NotifeeExtensionHelper.populateNotificationContent(request, with: self.bestAttemptContent!, withContentHandler: contentHandler)
Hi @LMakshow , I fell in the same trap with this doc missing information, can you confirm this is what the swift file should look like? Not sure I placed your line at the right place since the documentation is completely different on where to add it
import UserNotifications
import RNNotifeeCore
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
NotifeeExtensionHelper.populateNotificationContent(request, with: self.bestAttemptContent!, withContentHandler: contentHandler)
if let bestAttemptContent = bestAttemptContent {
// Modify the notification content here...
bestAttemptContent.title = "\(bestAttemptContent.title) [modified]"
contentHandler(bestAttemptContent)
}
}
override func serviceExtensionTimeWillExpire() {
// Called just before the extension will be terminated by the system.
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
contentHandler(bestAttemptContent)
}
}
}
@pierroo NotifeeExtensionHelper.populateNotificationContent will fire the notification to be shown, so you don't need any extra code after that. Otherwise, it's okay. XCode has quite a nice Swift IDE that will tell you about the errors if something is wrong.
import UserNotifications
import RNNotifeeCore
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
NotifeeExtensionHelper.populateNotificationContent(request, with: self.bestAttemptContent!, withContentHandler: contentHandler)
}
override func serviceExtensionTimeWillExpire() {
// Called just before the extension will be terminated by the system.
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
contentHandler(bestAttemptContent)
}
}
}
Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
Hi. I'm followed your instructions, but I've got "No such module 'RNNotifeeCore'" error on import RNNotifeeCore Please help!
@pavelustenko You probably didn't add the pod RNotifeeCore to your Podfile. You can find the guidance in the official doc: https://notifee.app/react-native/docs/ios/remote-notification-support#add-target-to-the-podfile
If after the "pod install --repo-update" command you encounter some use_frameworks or linkage error, you might also add the additional line to your Podfile, so the end of the Podfile will look like this:
$NotifeeExtension = true
target 'NotifeeNotificationService' do
use_frameworks! :linkage => :static
pod 'RNNotifeeCore', :path => '../node_modules/@notifee/react-native/RNNotifeeCore.podspec'
end
If after the "pod install --repo-update" command you encounter some use_frameworks or linkage error, you might also add the additional line to your Podfile, so the end of the Podfile will look like this:
$NotifeeExtension = true target 'NotifeeNotificationService' do use_frameworks! :linkage => :static pod 'RNNotifeeCore', :path => '../node_modules/@notifee/react-native/RNNotifeeCore.podspec' end
@LMakshow Thank you for your answer. Normally when I run pod install --repo-update I get the following output
pvu@Mac-mini-2 ios % pod install --repo-update Ignoring ffi-1.13.0 because its extensions are not built. Try: gem pristine ffi --version 1.13.0 RNFBApp: Using overridden static_framework value of 'true' Adding a custom script phase for Pod RNFBApp: [RNFB] Core Configuration RNFBCrashlytics: Using overridden static_framework value of 'true' Adding a custom script phase for Pod RNFBCrashlytics: [RNFB] Crashlytics Configuration RNFBMessaging: Using overridden static_framework value of 'true' Auto-linking React Native modules for target `ttyxx`: RNAudioRecorderPlayer, RNBootSplash, RNCAsyncStorage, RNCClipboard, RNDeviceInfo, RNFBApp, RNFBCrashlytics, RNFBMessaging, RNFS, RNFileViewer, RNFlashList, RNGestureHandler, RNImageCropPicker, RNNotifee, RNReactNativeHapticFeedback, RNReanimated, RNSVG, RNScreens, RNShare, RNSound, RNVectorIcons, react-native-background-timer, react-native-blob-util, react-native-document-picker, react-native-flipper, react-native-image-picker, react-native-image-resizer, react-native-mmkv, react-native-orientation, react-native-photo-view, react-native-receive-sharing-intent, react-native-safe-area-context, react-native-slider, react-native-sqlite-storage, react-native-version-number, and react-native-video Framework build type is static library [Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json Updating local specs repositories
CocoaPods 1.14.3 is available.
To update use: sudo gem install cocoapods
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.14.3
Analyzing dependencies [Codegen] Found FBReactNativeSpec RNFBApp: Using overridden static_framework value of 'true' RNFBCrashlytics: Using overridden static_framework value of 'true' RNFBMessaging: Using overridden static_framework value of 'true' [Codegen] Found rncore Downloading dependencies Generating Pods project Setting REACT_NATIVE build settings Setting CLANG_CXX_LANGUAGE_STANDARD to c++17 on /Users/pvu/TTYXX/ttyxx/ios/ttyxx.xcodeproj Pod install took 30 [s] to run Integrating client project Pod installation complete! There are 106 dependencies from the Podfile and 106 total pods installed.
[!] RNNotifee: using Notification Service Extension.
[!] The ttyxx [Debug]
target overrides the ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES
build setting defined in `Pods/Target Support Files/Pods-ttyxx/Pods-ttyxx.debug.xcconfig'. This can lead to problems with the CocoaPods installation
$(inherited)
flag, or[!] The ttyxx [Release]
target overrides the ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES
build setting defined in `Pods/Target Support Files/Pods-ttyxx/Pods-ttyxx.release.xcconfig'. This can lead to problems with the CocoaPods installation
$(inherited)
flag, orbut when I added
use_frameworks! :linkage => :static
pvu@Mac-mini-2 ios % pod install --repo-update
Ignoring ffi-1.13.0 because its extensions are not built. Try: gem pristine ffi --version 1.13.0
RNFBApp: Using overridden static_framework value of 'true'
Adding a custom script phase for Pod RNFBApp: [RNFB] Core Configuration
RNFBCrashlytics: Using overridden static_framework value of 'true'
Adding a custom script phase for Pod RNFBCrashlytics: [RNFB] Crashlytics Configuration
RNFBMessaging: Using overridden static_framework value of 'true'
Auto-linking React Native modules for target ttyxx
: RNAudioRecorderPlayer, RNBootSplash, RNCAsyncStorage, RNCClipboard, RNDeviceInfo, RNFBApp, RNFBCrashlytics, RNFBMessaging, RNFS, RNFileViewer, RNFlashList, RNGestureHandler, RNImageCropPicker, RNNotifee, RNReactNativeHapticFeedback, RNReanimated, RNSVG, RNScreens, RNShare, RNSound, RNVectorIcons, react-native-background-timer, react-native-blob-util, react-native-document-picker, react-native-flipper, react-native-image-picker, react-native-image-resizer, react-native-mmkv, react-native-orientation, react-native-photo-view, react-native-receive-sharing-intent, react-native-safe-area-context, react-native-slider, react-native-sqlite-storage, react-native-version-number, and react-native-video
Framework build type is static library
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
Updating local specs repositories
CocoaPods 1.14.3 is available.
To update use: sudo gem install cocoapods
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.14.3
Analyzing dependencies [Codegen] Found FBReactNativeSpec RNFBApp: Using overridden static_framework value of 'true' RNFBCrashlytics: Using overridden static_framework value of 'true' RNFBMessaging: Using overridden static_framework value of 'true' [Codegen] Found rncore [!] Unable to integrate the following embedded targets with their respective host targets (a host target is a "parent" target which embeds a "child" target like a framework or extension):
[!] RNNotifee: using Notification Service Extension.
My pod file looks like
require Pod::Executable.execute_command('node', ['-p', 'require.resolve( "react-native/scripts/react_native_pods.rb", {paths: [process.argv[1]]}, )', dir]).strip
platform :ios, min_ios_version_supported prepare_react_native_project!
react-native-flipper
your iOS build will fail when NO_FLIPPER=1
is set.react-native-flipper
depends on (FlipperKit,...) that will be excluded#
react-native-flipper
using a react-native.config.js
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
linkage = ENV['USE_FRAMEWORKS'] if linkage != nil Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green use_frameworks! :linkage => linkage.to_sym end
target 'ttyxx' do pod 'FirebaseCore', :modular_headers => true pod 'FirebaseCoreExtension', :modular_headers => true pod 'FirebaseInstallations', :modular_headers => true pod 'GoogleDataTransport', :modular_headers => true pod 'GoogleUtilities', :modular_headers => true pod 'nanopb', :modular_headers => true
$RNFirebaseAsStaticFramework = true
config = use_native_modules!
flags = get_default_flags()
use_react_native!( :path => config[:reactNativePath],
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
:flipper_configuration => flipper_config,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
target 'ttyxxTests' do inherit! :complete
end
post_install do |installer|
react_native_post_install(
installer,
config[:reactNativePath],
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end end $NotifeeExtension = true
target 'NotifeeNotificationService' do use_frameworks! :linkage => :static pod 'RNNotifeeCore', :path => '../node_modules/@notifee/react-native/RNNotifeeCore.podspec' end
@pavelustenko
Please try to add the same line in your main app target, right after "$RNFirebaseAsStaticFramework = true"
use_frameworks! :linkage => :static
@pavelustenko 👋 hello from the react-native-firebase maintainer
I need to be 100% crystal clear, these lines:
pod 'FirebaseCore', :modular_headers => true
pod 'FirebaseCoreExtension', :modular_headers => true
pod 'FirebaseInstallations', :modular_headers => true
pod 'GoogleDataTransport', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
pod 'nanopb', :modular_headers => true
Are an unsupported workaround that people commonly attempt to use in order to access react-native-firebase without using use_frameworks
No support for any build that has modular_headers
in it's Podfile anywhere will be provided
@mikehardy I appreciate your reaction, but we are currently in sinking boat with use_frameworks. RNFB does require use_frameworks. Using MMKV deprives us from using Chrome Debugger. They suggest to use Flipper instead. Flipper does not support use_frameworks and seems like Flipper Dev team ignores requests to do something about it for a very long time. Thus, we are left with a choice: remain without a debugger or without push-notifications.
@pavelustenko Well, I don't think that it's possible to use Obj-C pod (RNNotifeeCore) with a Swift extension without use_frameworks at all. So yep, I'd give up Flipper for iOS, but better have nice notifications. You can still use Flipper with Android build. And you can also check out Reactotron, it's not as robust as Flipper, but still a nice debugger.
Even worse, Flipper is deprecated and no one should recommend it's use any longer - it is being phased out of react-native
@pavelustenko You probably didn't add the pod RNotifeeCore to your Podfile. You can find the guidance in the official doc: https://notifee.app/react-native/docs/ios/remote-notification-support#add-target-to-the-podfile
If after the "pod install --repo-update" command you encounter some use_frameworks or linkage error, you might also add the additional line to your Podfile, so the end of the Podfile will look like this:
$NotifeeExtension = true target 'NotifeeNotificationService' do use_frameworks! :linkage => :static pod 'RNNotifeeCore', :path => '../node_modules/@notifee/react-native/RNNotifeeCore.podspec' end
add this line use_frameworks! :linkage => :static it's work for my case
Hi. I'm followed your instructions, but I've got "No such module 'RNNotifeeCore'" error on import RNNotifeeCore Please help!
This is happening to me too. Did you figure this out?
I've followed the documentation at https://notifee.app/react-native/docs/ios/remote-notification-support to the letter and I do not seem to be able to complete the tutorial due to the lack of a NotificationService.m file.
I've added the new target, checked it was definitely NotificationServiceExtension that I selected, and renamed it exactly as instructed. I then copied the code to be added to the podfile and ran pod install --repo-update, which informed me that the pods RNNotifee and RNNotifeeCore had been installed. I then come to the final stage of using the extension helper. It tells me to select the extension from the navigator which I do, then it tells me to select the NotificationService.m file which doesn't exist.
Attached is what is in my folder for the extenstion