CrossFirebasePushNotification.Current.OnNotificationReceived not enter in ios
NehaLOsamaFahmy opened this issue · 1 comments
I implemented push notifications in android work will, in ios token return but when try to test notifications not received, no error return to fix and didn't know what the problem please any help i stuck on this problem 2weeks
I use this plugin to implement firebase Plugin.FirebasePushNotification Version 3.4.35 Xamarin.Forms Version 5.0.0.2515
this Code in Add GoogleService-Info.plist file make build action BundleResources
Mark in Entitlements.plist push notifications to enable
Mark in info.plist Enable BackgroundMode (Remote notification), Add
<key>FirebaseAppDelegateProxyEnabled</key> <false/>
in Shared project add this
CrossFirebasePushNotification.Current.RegisterForPushNotifications();
CrossFirebasePushNotification.Current.OnTokenRefresh += (s, p) =>
{
System.Diagnostics.Debug.WriteLine($"TOKEN : {p.Token}");
if (p.Token != null)
{
AppData.Token = p.Token;
Api.CustomerService.UpdateTokenbynumber();
}
};
CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) =>
{
System.Diagnostics.Debug.WriteLine("Received");
System.Console.WriteLine($"**********Received : ");
};
CrossFirebasePushNotification.Current.OnNotificationOpened += (s, p) =>
{
System.Diagnostics.Debug.WriteLine("Opened");
};
CrossFirebasePushNotification.Current.OnNotificationAction += (s, p) =>
{
System.Diagnostics.Debug.WriteLine("Action");
};
CrossFirebasePushNotification.Current.OnNotificationError += (s, p) =>
{
System.Diagnostics.Debug.WriteLine("Errrrrrrroooooooorrrr");
};
this Code in AppDelegate
Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
Xamarin.FormsGoogleMaps.Init("AIzaSyAFh07QpEGWHSecHRTxImrctCZAge0WK5o");
Xamarin.Forms.Forms.SetFlags("IndicatorView_Experimental");
Rg.Plugins.Popup.Popup.Init();
global::Xamarin.Forms.Forms.Init();
Firebase.Core.App.Configure();
Plugin.LocalNotification.LocalNotificationCenter.RequestNotificationPermission();
FirebasePushNotificationManager.Initialize(options, true);
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
FirebasePushNotificationManager.DidRegisterRemoteNotifications(deviceToken);
Console.WriteLine($"Firebase registration token: {AppData.Token}");
}
public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
{
FirebasePushNotificationManager.RemoteNotificationRegistrationFailed(error);
}
// To receive notifications in foregroung on iOS 9 and below.
// To receive notifications in background in any iOS version
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
{
// If you are receiving a notification message while your app is in the background,
// this callback will not be fired 'till the user taps on the notification launching the application.
// If you disable method swizzling, you'll need to call this method.
// This lets FCM track message delivery and analytics, which is performed
// automatically with method swizzling enabled.
FirebasePushNotificationManager.DidReceiveMessage(userInfo);
// Do your magic to handle the notification data
System.Console.WriteLine(userInfo);
completionHandler(UIBackgroundFetchResult.NewData);
}
}
this log data
2022-11-21 14:17:32.772818+0200 Najd.iOS[17253:179449] [general] *** -[NSKeyedUnarchiver validateAllowedClass:forKey:] allowed unarchiving safe plist type ''NSNumber' (0x7ff863b6e4d0) [/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Foundation.framework]' for key 'NS.keys', even though it was not explicitly included in the client allowed classes set: '{(
"'NSMutableSet' (0x7ff863b571d0) [/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework]",
"'GDTCOREvent' (0x1019a5168) [/Users/raitotec/Library/Developer/CoreSimulator/Devices/D39EF3A7-186B-4AA8-B1B6-7068F966D261/data/Containers/Bundle/Application/6E5BD3FC-B9A7-41F2-95D4-99EE7783B900/Najd.iOS.app/Frameworks/GoogleDataTransport.framework]",
"'N
SMutableDictionary' (0x7ff863b585f8) [/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework]"
)}'. This will be disallowed in the future.
Thread started: <Thread Pool> #2
Thread started: <Thread Pool> #3
Thread started: <Thread Pool> #4
Thread started: <Thread Pool> #5
Loaded assembly: /Users/raitotec/Library/Developer/CoreSimulator/Devices/D39EF3A7-186B-4AA8-B1B6-7068F966D261/data/Containers/Bundle/Application/6E5BD3FC-B9A7-41F2-95D4-99EE7783B900/Najd.iOS.app/ar/Najd.resources.dll [External]
2022-11-21 14:18:11.996099+0200 Najd.iOS[17253:180223] 6.22.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization.
2022-11-21 14:18:12.071362+0200 Najd.iOS[17253:180223] [general] *** -[NSKeyedUnarchiver validateAllowedClass:forKey:] allowed unarchiving safe plist type ''NSString' (0x7ff863b6d698) [/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Foundation.framework]' for key 'NS.keys', even though it was not explicitly included in the client allowed classes set: '{(
"'NSDictionary' (0x7ff863b589e0) [/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework]",
"'NSDate' (0x7ff863b58878) [/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework]"
)}'. This w
ill be disallowed in the future.
Thread started: #7
2022-11-21 14:18:19.031547+0200 Najd.iOS[17253:179449] **********TOKEN : er8MQGevkkV7rSosJS9_NP:APA91bETxB3GAJQxR728lmHm9rMTaa3jS06nXFDkNcdXJ7pkEi1t3JwxSzqyYk8nH5k90UgZ16WtxDmrzuCA81AzsnTOdh6h_fkVtkmZCgYbaU0cMW1yAJl-K2qSfIlOYbzT0MXBYqU-
2022-11-21 14:18:19.287594+0200 Najd.iOS[17253:180223] [general] *** -[NSKeyedUnarchiver validateAllowedClass:forKey:] allowed unarchiving safe plist type ''NSString' (0x7ff863b6d698) [/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Foundation.framework]' for key 'NS.keys', even though it was not explicitly included in the client allowed classes set: '{(
"'NSDictionary' (0x7ff863b589e0) [/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework]",
"'NSDate' (0x7ff863b58878) [/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework]"
)}'. This w
ill be disallowed in the future.
2022-11-21 14:18:19.336678+0200 Najd.iOS[17253:180330] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x6000031ee540> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2022-11-21 14:18:19.339800+0200 Najd.iOS[17253:179942] 6.22.0 - <AppMeasurement>[I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
In the shared project there is no need to call CrossFirebasePushNotification.Current.RegisterForPushNotifications();
This is already done in Appdelegate. To test with ios you need a real device. With simulator testing is difficult.