-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[question]: Please can someone help I can't find anything in the documentation to get this code working #639
Comments
I have already tried: TroubleshootingIf you run into the following errors :
If you would like to regenerate the OneSignal assets, remove the OneSignal Unity SDK packages (Android, Core, iOS) from your project and import the OneSignal SDK again. |
Checkout Migration Guide 5.0.2 version of your code is: public virtual void Initialize() {
OneSignal.Initialize(appId);
OneSignal.Notifications.Clicked += HandleNotificationClicked;
OneSignal.Notifications.ForegroundWillDisplay += HandleNotificationWillShow;
}
protected virtual void HandleNotificationClicked(object sender, NotificationClickEventArgs notification) {
// Handle opened notification
}
protected virtual void HandleNotificationWillShow(object sender, NotificationWillDisplayEventArgs notification) {
notification.PreventDefault();
} |
We have a list of 5.x methods in our migration guide and in our docs: You can also see our example app code here As AFB-MORA suggested,
We have changed events to use EventHandlers - your code should look something like this private void HandleNotificationClicked(object sender, NotificationClickEventArgs e) {
// You can access the notification and result with
e.Notification;
e.Result;
} private void HandleNotificationWillShow(object sender, NotificationWillDisplayEventArgs e) {
// You can access the notification and choose to display it
e.Notification;
// You can also prevent OneSignal from displaying the notification immediately on return with e.PreventDefault()
// This way you can edit the notification before it displays
// Display the notification with
e.Notification.Display();
} Let me know if you have any issues We are currently working on documentation to make upgrading clearer that has a list of method changes/renames from 3.x to 5.x |
Going to close this issue for now, let me know if you have any further questions |
Using Unity 2022.3.9f1
I've upgraded to version 5.0.2 from 3.0.x
OneSignal.NotificationOpened: 'OneSignal does not contain a definition for NotificationOpened'
OneSignal.NotificationWillShow: 'OneSignal does not contain a definition for NotificationWillShow '
Notification: 'The type or namespace name Notification could not be found'
NotificationOpenedResult : 'The type or namespace name NotificationOpenedResult could not be found'
Losing my mind with this upgrade.
The text was updated successfully, but these errors were encountered: