Comments (14)
Well, I thought this made sense but i'm calling CrossPushNotification.Current.RegisterForPushNotifications() in the new version and I am receiving notifications, but they don't go to the OnNotificationOpened. Is there something in the Initialize(options,true) besides the user permissions that might impact the OnNotificationOpened not being called? I'll still try out the autoregister
from pushnotificationplugin.
iOS by default receive the notification only when tapped. If you want to receive it when arrive should send content-available: 1
More info here:
from pushnotificationplugin.
The issue is the when I click the notification it opens the app and the OnNotificationReceived event is called, but not the OnNotificationOpened. This works on Android but not on iOS, and used to work on iOS
from pushnotificationplugin.
How are tou initializing the plugin on iOS?
from pushnotificationplugin.
Here's the main area
LoadApplication(new App()); PushNotificationManager.Initialize(options, false); return base.FinishedLaunching(app, options);
from pushnotificationplugin.
And then this.
` public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
PushNotificationManager.DidRegisterRemoteNotifications(deviceToken);
}
public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
{
PushNotificationManager.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)
{
PushNotificationManager.DidReceiveMessage(userInfo);
}`
from pushnotificationplugin.
I did revert back to version 1.2.6 and the OnNotificationOpened worked with no application changes except the new CrossPushNotification.Current.RegisterForPushNotifications() was commented out.
I also tried 1.2.8-beta and that didn't work either. So either I need to do something different with 1.3.0 or something isn't quite right.
Thanks again
from pushnotificationplugin.
Ok the problem seems to be here you are setting autoRegister to false when initializing.
PushNotificationManager.Initialize(NSDictionary options,bool autoRegistration) : Default method to initialize plugin without supporting any user notification categories. Auto registers for push notifications if second parameter is true.
If you do that you need to call CrossPushNotification.Current.RegisterForPushNotifications() at some point. Because is where it gets the delegate set.
from pushnotificationplugin.
PushNotificationManager.Initialize(options,true)
If auto register true will call CrossPushNotification.Current.RegisterForPushNotifications() internally. Which is where delegate is set.
PushNotificationManager.Initialize(options,false)
If auto register false won't call CrossPushNotification.Current.RegisterForPushNotifications(). Which is where delegate is set , so you need to call CrossPushNotification.Current.RegisterForPushNotifications() manually at the point you desire permissions are asked.
from pushnotificationplugin.
from pushnotificationplugin.
mmm shouldn't impact unless you assign UNUserNotificationCenter.Current.Delegate after that call which is assigned internally. Here is what it does internally:
public async Task RegisterForPushNotifications()
{
TaskCompletionSource<bool> permisionTask = new TaskCompletionSource<bool>();
// Register your app for remote notifications.
if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
{
// iOS 10 or later
var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.Current.Delegate = CrossPushNotification.Current as IUNUserNotificationCenterDelegate;
UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) =>
{
if (error != null)
_onNotificationError?.Invoke(CrossPushNotification.Current, new PushNotificationErrorEventArgs(PushNotificationErrorType.PermissionDenied, error.Description));
else if (!granted)
_onNotificationError?.Invoke(CrossPushNotification.Current, new PushNotificationErrorEventArgs( PushNotificationErrorType.PermissionDenied,"Push notification permission not granted"));
permisionTask.SetResult(granted);
});
}
else
{
// iOS 9 or before
var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
var settings = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
permisionTask.SetResult(true);
}
var permissonGranted = await permisionTask.Task;
if (permissonGranted)
{
UIApplication.SharedApplication.RegisterForRemoteNotifications();
}
}
And when you initialize it basically just calls this method if true
public static async Task Initialize(NSDictionary options, bool autoRegistration = true)
{
CrossPushNotification.Current.NotificationHandler = CrossPushNotification.Current.NotificationHandler ?? new DefaultPushNotificationHandler();
if (autoRegistration)
{
await CrossPushNotification.Current.RegisterForPushNotifications();
}
}
from pushnotificationplugin.
Are you still having this issue?
from pushnotificationplugin.
Let me know if still having this issue.
from pushnotificationplugin.
Will close this for now because can't reproduce, if still happening for you feel free to reopen it.
from pushnotificationplugin.
Related Issues (20)
- This plugin vs FirebasePushNotificationPlugin HOT 6
- Strange behaviour in IOS HOT 1
- Crash on iOS with version 3.6.9 when tapping notification HOT 2
- The Sample solution does not show the notification
- Initialization Exception in push notification plugin
- Is there possibility to only show specified by payload value on iOS?
- On iOS, "UNNotificationPresentationOptions.Sound" never turns off once it's been activated
- Android dependencies - Not receiving notifications on Android HOT 1
- Android DefaultPushNotificationHandler "silent" flag not case sensitive
- Why do we have to reset token during debug?
- Missing Xamarin.Firebase.Iid package referenced by this plugin HOT 2
- Icon problem
- Android 12 and missing android:exported attribute HOT 15
- iOS 15.4.1 don't open push notification HOT 2
- FirebaseApp is not initialized HOT 2
- .net6 and Maui support? HOT 2
- PNMessagingService Service class requires an Exported attribute starting from Android 12 HOT 1
- How to enable "CriticalAlert" using this plugin? HOT 1
- no valid “aps-environment” entitlement string found for application
- Is there any plan to release this Library for . NET MAUI
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pushnotificationplugin.