Skip to content
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]: Possibility to handle notification interactions #669

Closed
1 task done
icr4 opened this issue Nov 25, 2023 · 2 comments
Closed
1 task done

[question]: Possibility to handle notification interactions #669

icr4 opened this issue Nov 25, 2023 · 2 comments

Comments

@icr4
Copy link

icr4 commented Nov 25, 2023

How can we help?

Does this plugin offers a way to "handle" when an user taps on the notification?
It should, by default, open the app. But is there any way to handle some custom parameters sent from the initial notification payload and permit Unity to do specific operations?

Another smaller question is, does it works good when the mobile app is closed?

Code of Conduct

  • I agree to follow this project's Code of Conduct
@shepherd-l
Copy link
Contributor

shepherd-l commented Nov 29, 2023

Yes, we have a notification click listener you can use to handle when a user taps on a notification.
https://documentation.onesignal.com/docs/mobile-sdk#setting-notification-click-listeners

From it, you can access the Notification and NotificationClickResult in Unity. (They have fields that are defined here and here).

It should look something like this:

OneSignal.Notifications.Clicked += (sender, e) =>
  {
    	// Access the notification with e.Notification and the click result with e.Result
	
	// string rawPayload = e.Notification.RawPayload;
	// IDictionary<string, object> additionalData = e.Notification.AdditionalData;
  };

You can also see an example of a listener in our example app: https://github.com/OneSignal/OneSignal-Unity-SDK/blob/5.0.5/com.onesignal.unity.core/Samples~/OneSignalExampleBehaviour.cs#L168

By custom parameters do you mean the raw payload or additional data?

A notification will display in the foreground even when the app is closed. Tapping on the notification will open the app and still fire the notification click listener.

Let us know if you have any questions

@shepherd-l
Copy link
Contributor

Closing this issue, please open a new issue if you have any questions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants