i think your code is outdated. the documentaion show us how to request permission it it uses "var request = new PermissionRequest();" now Permession class
Thanks for the video, it really helped me, but I have a question. In 4:35, will it work if I change the line 34 for a variable type DateTime with the date and hour that I want to send the notification? And, if it would work, How?😅 Thanks again.😄😄
Nice tutorial. With the code as it is provided by you, every time the user opens the app, a new notification is scheduled. And also the nice badge is not shown. I liked your architecture, btw. i used to have one file and the code was a bit messy...
Bro it's work in my android api 33. I have to do on notification form app settings then its work but i want that notification popup show and user all and automatically on notification permission
Try combine with: if (!Permission.HasUserAuthorizedPermission("android.permission.POST_NOTIFICATIONS")) { Permission.RequestUserPermission("android.permission.POST_NOTIFICATIONS"); } somewhere at the beginning of your app loading logic
is there any way to set conditions for notifications? I want to access functions from other files in the program and send notifications based on the return value, and also if theres a way to get an apis response and send a notification based on that?
You need to know content of the notification when you schedule it. If its content changes after you schedule it you should remove previous schedule and set it again - however application need to be opened then. For any other cases you will probably need to use cloud based notification, I have a plan to create tutorial about it in the future 🙂
But generally content doesn’t have to be static, it can be dynamic. Just take values and put them in to content (if you know the content when scheduling).
Great tutorial Mate!!! But, I have problem with iOS notification. Notification gets displayed when video ad is being played. I just want to display notifications when app is minimized or when app is closed. Any fix for this?
Thanks! Notifications are scheduled using iOS API so you need to handle when app launch and cancel all notifications and then set them again when app closes. There is no way to check if app is running when displaying notification sadly.
Hm, maybe force closing cause that system request is not proceed successfully. I’m not sure. Maybe it’s somehow system-dependent. I’m not sure if there is an option to avoid it. There is also second type of notifications, those one pushed from the server, but this is much more complicated than calling system API.
Bro Show me error: Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'AndroidNotificationChannel' could not be found (are you missing a using directive or an assembly reference?) Assembly-CSharp, Assembly-CSharp.Player C:\Users\DREAMWORLD\Work From Home Task\Assets\Scripts\AndroidNotificationsController.cs 20 Active Error CS0246 The type or namespace name 'AndroidNotification' could not be found (are you missing a using directive or an assembly reference?) Assembly-CSharp, Assembly-CSharp.Player C:\Users\DREAMWORLD\Work From Home Task\Assets\Scripts\AndroidNotificationsController.cs 32 Active Error CS0103 The name 'NotificationManager' does not exist in the current context Assembly-CSharp, Assembly-CSharp.Player C:\Users\DREAMWORLD\Work From Home Task\Assets\Scripts\AndroidNotificationsController.cs 27 Active Error CS0103 The name 'NotificationManager' does not exist in the current context Assembly-CSharp, Assembly-CSharp.Player C:\Users\DREAMWORLD\Work From Home Task\Assets\Scripts\AndroidNotificationsController.cs 37 Active Error CS0103 The name 'NotificationImportance' does not exist in the current context Assembly-CSharp, Assembly-CSharp.Player C:\Users\DREAMWORLD\Work From Home Task\Assets\Scripts\AndroidNotificationsController.cs 24 Active
It seems like you using Assembly Defines in your project. Because of that, reference will not be found automatically. You need to find Assembly Define you use with this script inside your project and manually add Unity.Notifications.Android (or Unity.Notifications.iOS for iOS) to the "Assembly Definition References" list.
Hi! To send notification on newer Android versions (I'm not sure, but starting from Android 13 probably) you need to ask for permission to do that. This is what Permission.RequestUserPermission do. But when user respond for this permission (no matter if they agree or reject) we don't want to ask them anymore for this permission. Without this if statement the user would be asked for this permission on every game launching. 😅
And the "text" is just the name of permission we want to ask for. In this case we ask for notification permission so we need to use "android.permission.POST_NOTIFICATIONS". Other permissions are listed in Android documentation.
14:28 Oglądałem ten tutorial i tak coś czułem ten polski akcent xD
Ale dobra robota z tym filmem :D
Ah, akcentu nie oszukasz 😅
brother thanks . i want to make unity sound running while the screen is of or locked
Thanks, clear tutorial!
Hi. I saw your fantastic tutorials. Vibration video, Notification video. Thanks of lot! :)
i think your code is outdated. the documentaion show us how to request permission it it uses "var request = new PermissionRequest();" now Permession class
Great tutorial!
Would it be possible to add a click event for when the user taps the notification while the app is in the foreground?
Thanks for the tutorial
Thanks for the video, it really helped me, but I have a question. In 4:35, will it work if I change the line 34 for a variable type DateTime with the date and hour that I want to send the notification? And, if it would work, How?😅 Thanks again.😄😄
Fantastic tutorial, thank you!
Nice tutorial. With the code as it is provided by you, every time the user opens the app, a new notification is scheduled. And also the nice badge is not shown. I liked your architecture, btw. i used to have one file and the code was a bit messy...
Amazing, thank you!
Bro it's work in my android api 33. I have to do on notification form app settings then its work but i want that notification popup show and user all and automatically on notification permission
Try combine with:
if (!Permission.HasUserAuthorizedPermission("android.permission.POST_NOTIFICATIONS")) { Permission.RequestUserPermission("android.permission.POST_NOTIFICATIONS"); }
somewhere at the beginning of your app loading logic
is there any way to set conditions for notifications? I want to access functions from other files in the program and send notifications based on the return value, and also if theres a way to get an apis response and send a notification based on that?
You need to know content of the notification when you schedule it. If its content changes after you schedule it you should remove previous schedule and set it again - however application need to be opened then. For any other cases you will probably need to use cloud based notification, I have a plan to create tutorial about it in the future 🙂
But generally content doesn’t have to be static, it can be dynamic. Just take values and put them in to content (if you know the content when scheduling).
How to send notification when user doesn't open the app?
You need to somehow schedule the notification. If you want to send notifications without this you need to use Firebase Cloud Messaging.
Great tutorial! Thanks 😊
Great tutorial Mate!!!
But, I have problem with iOS notification. Notification gets displayed when video ad is being played. I just want to display notifications when app is minimized or when app is closed. Any fix for this?
Thanks! Notifications are scheduled using iOS API so you need to handle when app launch and cancel all notifications and then set them again when app closes. There is no way to check if app is running when displaying notification sadly.
Great tutorial but, this is not working when the app is close, isn't it?
It is! When you set up notification to push eg. in 5 minutes it will be shown to user in 5 minutes even if the app is closed.
@@blazeDev_vlog but not if it is force closed, maybe I miss some configuration?
Hm, maybe force closing cause that system request is not proceed successfully. I’m not sure. Maybe it’s somehow system-dependent. I’m not sure if there is an option to avoid it. There is also second type of notifications, those one pushed from the server, but this is much more complicated than calling system API.
make a tutorial for Firebase cloud messaging, and how to implement permissions for showing notifications for IOS , there are no tutorials at all
Noted on my todo list, I will take a look at this. Thanks!
Bro, thank you. I was about to give up implementing the IOS one as I kept getting the errors and didn't know how to fix them without your help
Happy to hear that! 💪
Great
Bro Show me error:
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'AndroidNotificationChannel' could not be found (are you missing a using directive or an assembly reference?) Assembly-CSharp, Assembly-CSharp.Player C:\Users\DREAMWORLD\Work From Home Task\Assets\Scripts\AndroidNotificationsController.cs 20 Active
Error CS0246 The type or namespace name 'AndroidNotification' could not be found (are you missing a using directive or an assembly reference?) Assembly-CSharp, Assembly-CSharp.Player C:\Users\DREAMWORLD\Work From Home Task\Assets\Scripts\AndroidNotificationsController.cs 32 Active
Error CS0103 The name 'NotificationManager' does not exist in the current context Assembly-CSharp, Assembly-CSharp.Player C:\Users\DREAMWORLD\Work From Home Task\Assets\Scripts\AndroidNotificationsController.cs 27 Active
Error CS0103 The name 'NotificationManager' does not exist in the current context Assembly-CSharp, Assembly-CSharp.Player C:\Users\DREAMWORLD\Work From Home Task\Assets\Scripts\AndroidNotificationsController.cs 37 Active
Error CS0103 The name 'NotificationImportance' does not exist in the current context Assembly-CSharp, Assembly-CSharp.Player C:\Users\DREAMWORLD\Work From Home Task\Assets\Scripts\AndroidNotificationsController.cs 24 Active
It seems like you using Assembly Defines in your project. Because of that, reference will not be found automatically. You need to find Assembly Define you use with this script inside your project and manually add Unity.Notifications.Android (or Unity.Notifications.iOS for iOS) to the "Assembly Definition References" list.
!permission.HasUserAuthorizePermission("text") what that means?
Hi! To send notification on newer Android versions (I'm not sure, but starting from Android 13 probably) you need to ask for permission to do that. This is what Permission.RequestUserPermission do. But when user respond for this permission (no matter if they agree or reject) we don't want to ask them anymore for this permission. Without this if statement the user would be asked for this permission on every game launching. 😅
And the "text" is just the name of permission we want to ask for. In this case we ask for notification permission so we need to use "android.permission.POST_NOTIFICATIONS". Other permissions are listed in Android documentation.
why i love unreal more than unity?@@blazeDev_vlog