iOS Notification not showing when app is in background/not running
See original GitHub issueI’ve setup iOS env
AppDelegate.h
@import UserNotifications;
@interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate>
AppDelegate.m
#import "RNFIRMessaging.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
...
return [[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{
[RNFIRMessaging willPresentNotification:notification withCompletionHandler:completionHandler];
}
#if defined(__IPHONE_11_0)
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
{
[RNFIRMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
}
#else
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler
{
[RNFIRMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
}
#endif
//You can skip this method if you don't want to use local notification
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
[RNFIRMessaging didReceiveLocalNotification:notification];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
[RNFIRMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
Podfile
PODS:
- AppsFlyerFramework (4.8.1)
- Firebase/Core (4.8.0):
- FirebaseAnalytics (= 4.0.5)
- FirebaseCore (= 4.0.13)
- Firebase/Messaging (4.8.0):
- Firebase/Core
- FirebaseMessaging (= 2.0.8)
- FirebaseAnalytics (4.0.5):
- FirebaseCore (~> 4.0)
- FirebaseInstanceID (~> 2.0)
- GoogleToolboxForMac/NSData+zlib (~> 2.1)
- nanopb (~> 0.3)
- FirebaseCore (4.0.13):
- GoogleToolboxForMac/NSData+zlib (~> 2.1)
- FirebaseInstanceID (2.0.8):
- FirebaseCore (~> 4.0)
- FirebaseMessaging (2.0.8):
- FirebaseAnalytics (~> 4.0)
- FirebaseCore (~> 4.0)
- FirebaseInstanceID (~> 2.0)
- GoogleToolboxForMac/Logger (~> 2.1)
- Protobuf (~> 3.1)
- GoogleAppUtilities (1.1.2):
- GoogleSymbolUtilities (~> 1.1)
- GoogleAuthUtilities (2.0.2):
- GoogleNetworkingUtilities (~> 1.2)
- GoogleSymbolUtilities (~> 1.1)
- GoogleNetworkingUtilities (1.2.2):
- GoogleSymbolUtilities (~> 1.1)
- GoogleSignIn (4.1.1):
- GoogleToolboxForMac/NSDictionary+URLArguments (~> 2.1)
- GoogleToolboxForMac/NSString+URLArguments (~> 2.1)
- GTMOAuth2 (~> 1.0)
- GTMSessionFetcher/Core (~> 1.1)
- GoogleSymbolUtilities (1.1.2)
- GoogleToolboxForMac/DebugUtils (2.1.3):
- GoogleToolboxForMac/Defines (= 2.1.3)
- GoogleToolboxForMac/Defines (2.1.3)
- GoogleToolboxForMac/Logger (2.1.3):
- GoogleToolboxForMac/Defines (= 2.1.3)
- GoogleToolboxForMac/NSData+zlib (2.1.3):
- GoogleToolboxForMac/Defines (= 2.1.3)
- GoogleToolboxForMac/NSDictionary+URLArguments (2.1.3):
- GoogleToolboxForMac/DebugUtils (= 2.1.3)
- GoogleToolboxForMac/Defines (= 2.1.3)
- GoogleToolboxForMac/NSString+URLArguments (= 2.1.3)
- GoogleToolboxForMac/NSString+URLArguments (2.1.3)
- GoogleUtilities (1.3.2):
- GoogleSymbolUtilities (~> 1.1)
- GTMOAuth2 (1.1.6):
- GTMSessionFetcher (~> 1.1)
- GTMSessionFetcher (1.1.12):
- GTMSessionFetcher/Full (= 1.1.12)
- GTMSessionFetcher/Core (1.1.12)
- GTMSessionFetcher/Full (1.1.12):
- GTMSessionFetcher/Core (= 1.1.12)
- nanopb (0.3.8):
- nanopb/decode (= 0.3.8)
- nanopb/encode (= 0.3.8)
- nanopb/decode (0.3.8)
- nanopb/encode (0.3.8)
- Protobuf (3.5.0)
DEPENDENCIES:
- AppsFlyerFramework
- Firebase/Core
- Firebase/Messaging
- FirebaseInstanceID
- GoogleAppUtilities
- GoogleAuthUtilities
- GoogleNetworkingUtilities
- GoogleSignIn
- GoogleSymbolUtilities
- GoogleUtilities
SPEC CHECKSUMS:
AppsFlyerFramework: 4f6fe2b018e1c2ca4f390652f3548a8ee799a610
Firebase: 710decbbc6d9d48530e9a5dba3209740c3532e05
FirebaseAnalytics: 5b02a63ead2c3f0259cfc7f15e053e440587ecf8
FirebaseCore: 3c02ec652db3d03fdc8bc6d9154af3e20d64b6f5
FirebaseInstanceID: 81df5805a08001e69138664bdd02c6719a9ac80f
FirebaseMessaging: dfdcd307c2382290a1e297a81d0f18370f5b1bcd
GoogleAppUtilities: a8a552aa74f6597f805e45b5a3962766c3134973
GoogleAuthUtilities: ccad2e0a9284699973ff57c0dd24c3893657fda4
GoogleNetworkingUtilities: 3edd3a8161347494f2da60ea0deddc8a472d94cb
GoogleSignIn: 3fdaa34a2ba04dbd7a25d7db39aecb0da98d5bdc
GoogleSymbolUtilities: 631ee17048aa5e9ab133470d768ea997a5ef9b96
GoogleToolboxForMac: 2501e2ad72a52eb3dfe7bd9aee7dad11b858bd20
GoogleUtilities: 8bbc733218aad26306f9d4a253823986110e3358
GTMOAuth2: c77fe325e4acd453837e72d91e3b5f13116857b2
GTMSessionFetcher: ebaa1f79a5366922c1735f1566901f50beba23b7
nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
Protobuf: 8a9838fba8dae3389230e1b7f8c104aa32389c03
PODFILE CHECKSUM: dd7e3472c814e6c1babda6de904737c6ae4ab939
COCOAPODS: 1.3.1
react-native 0.48.4 react-native-fcm 11.0.1 iPhone 7 Plus iOS 10.3.3 (AdHoc provisioning profile)
The notifications works when the app is in foreground.
Any ideas? Thanks
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Push Notification in Background not working iOS12 Swift4.2
But I am not able to get push notifications while background and foreground. Even not getting "Message Data" print while app in background....
Read more >Push notification in Background wo… | Apple Developer Forums
Push notification in Background works fine when App runs by Xcode, but does not work when App runs by itself.
Read more >iOS Background Notifications are not working #3699 - GitHub
Issue. iOS Background Notifications are not working. But It's working without any issue in the Foreground.
Read more >Silent push notification (background) not received on macOS ...
... push notification (background) not received on macOS Catalina (Catalyst app) ... push notifications to Apple Watch, and recommends it for all platforms....
Read more >awesome_notifications | Flutter Package - Pub.dev
Working progress percentages of awesome notifications plugin ... Do not forces the app to go foreground and runs on background, not accepting any...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@maggialejandro custom_notification is only for Android. for iOS you need
notification
. by the waycontentAvailable
should becontent_available
that fixed the problem! thanks!