iOS Question Dude, where's my notification?

Sandman

Expert
Licensed User
Longtime User
I'm trying to figure out some things with notifications (thread for that), but all of a sudden I'm unable to make even the most basic notification show. For instance, this code produces nothing:
B4X:
Dim ln As Notification
ln.Initialize(DateTime.Now)
ln.AlertBody = "Woop woop"
ln.PlaySound = True
ln.Register

Granted, I'm somewhat clueless when it comes to basic iPhone usage, so I might have fat-fingered something on the device when fiddling with a notification. I can, however, say with certainty that I haven't gone into Settings and changed anything.

I can't for the life of me find any problems. Here's what I've checked and tried, without success:
  • Restarted the iPhone
  • Cleaned the project
  • Changed the package name
  • Checked in Settings that the app is allowed to show notification
  • Checked in Settings that I didn't mistakenly activate Do Not Disturb
I have no idea what else to do to get back basic notifications. I should also mention that I have no real app usage on the device (and no SIM card or email setup) so there's really nothing else producing notifications.

Any ideas from our experienced iPhone users? :cool:
 

Alexander Stolte

Expert
Licensed User
Longtime User
Dude, here is your notification:
B4X:
Dim UNC As UserNotificationCenter
UNC.Initialize
UNC.SetCategoryActions("Category1", Array("Action1", "Action2"))
UNC.CreateNotificationWithContent("YourAppName","Dude, here is your Notification"), "parking_timer", "Category1", DateTime.TicksPerMinute)'1 Notification in 1 Minute
 

Attachments

  • UserNotificationCenter.bas
    3.8 KB · Views: 108
Upvote 0

Sandman

Expert
Licensed User
Longtime User
Dude, here is your notification:
B4X:
Dim UNC As UserNotificationCenter
UNC.Initialize
UNC.SetCategoryActions("Category1", Array("Action1", "Action2"))
UNC.CreateNotificationWithContent("YourAppName","Dude, here is your Notification"), "parking_timer", "Category1", DateTime.TicksPerMinute)'1 Notification in 1 Minute
Thanks Alexander, but I can't get this to work either. (Btw, you have an extra ")" at the end of the notification text.)

But I take it it works for you? I've exported my project, would you mind testing it to see if you get a notification?
 

Attachments

  • TestB4iNotifications.zip
    3.9 KB · Views: 116
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
But I take it it works for you?
Yes, the code is from the uPark+ app.

I've exported my project, would you mind testing it to see if you get a notification?
You need to add this code in the main module (Private Sub Application_Start (Nav As NavigationController)):
B4X:
App.RegisterUserNotifications(True, True, True)
UNC.Initialize 'after calling App.RegisterUserNotifications
Then it should work
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
Thanks, I added that code. Cleaned the project and tried again. This time I got a question when starting the app: "This app wants to send you notifications etc", which I approved.

Triggered notification - nothing happened.

Cleaned and compiled a release version - nothing happened.

Verified in Settings that I didn't pick wrong notification answer when asked - it's set to allow.

Changed package name and tried again - nothing happened.

I feel like I'm eating crazy-pills here, this seems insane. Why isn't it possible for me to produce a notification?

(I did manage to verify that the iPhone can produce notifications thanks to the built-in app Reminders.)
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Have you tested in release mode? The notification is sent after 1 minute according to my code. And put the app in the background
I'm not home, so i cant test your project.

The notification is only displayed at the top when the app is in the background
 
Upvote 1

Sandman

Expert
Licensed User
Longtime User
The notification is only displayed [...] when the app is in the background
Ugh, this was the central piece of info that I had forgotten. Well, that wasted a full workday.

So, I set the time to a minute again, made a release version and shoved it into the background - worked like a charm.

Thanks for your help Alexander, much appreciated!
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
So, I set the time to a minute again, made a release version and shoved it into the background - worked like a charm.
Works also in debug mode, as long as the app is still running in the ide
Ugh, this was the central piece of info that I had forgotten. Well, that wasted a full workday.
It's always the simplest things....
Thanks for your help Alexander, much appreciated!
You welcome
 
Upvote 0
Top