How to set the App Notification Badge ...

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
MadManSoft
Posts: 36
Joined: Fri Apr 12, 2013 9:15 pm

Local Notifications question

Post by MadManSoft » Sat Mar 29, 2014 4:44 pm

Just want to check that I'm not missing something...

I create a local notification. It doesn't display the banner while the app is open, but is in the notification center if I pull it down.

Is this normal? If it is, how do I get that banner displayed? iMessage would be the example. You are in a different message and new one comes in. It displays in a banner.

If it's not normal, then I'll go back and check in older versions to see where it breaks.

Thanks!

Steve MacLean

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Local Notifications question

Post by LCNeil » Mon Mar 31, 2014 2:35 pm

Hi Steven,

What you are trying to achieve is not directly possible with local notification in LiveCode and I am not sure if it is directly possible in general (e.g. with Xcode). I have researched this and come across many stackoverFlow posts that mention you have to essentially fake it. e.g.

http://stackoverflow.com/questions/1816 ... foreground

http://stackoverflow.com/questions/1487 ... ground-ios

This is also confirmed in the Apple Docs here-

https://developer.apple.com/library/ios ... rence.html
If the application is foremost and visible when the system delivers the notification, no alert is shown, no icon is badged, and no sound is played. However, the application:didReceiveLocalNotification: is called if the application delegate implements it. The UILocalNotification instance is passed into this method, and the delegate can check its properties or access any custom data from the userInfo dictionary.
As this is the case, I beleive we are able to handle this message with LiveCodes "localNotificationReceived" message and this will allow you to handle any notifications recieved when the app is open e.g.

Code: Select all

on localNotificationReceived tMessage
   answer "Local Notification:" && quote & tMessage & quote with "Okay"
end localNotificationReceived

Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
——

MadManSoft
Posts: 36
Joined: Fri Apr 12, 2013 9:15 pm

Re: Local Notifications question

Post by MadManSoft » Mon Mar 31, 2014 3:31 pm

Hi Neil,

I do see that, thanks for the links. I also see that it is possible to do what I would like to do (via those stack overflow links) using some 3rd party controls for xCode. And, Apple does this for it's own apps, though probably through a private API that we can't access.

Here is my problem:

When the app is open, I do get the push notification although NOT any message. See my addition to bug #http://quality.runrev.com/show_bug.cgi?id=10901 and have worked around that for the time being. It's not displayed, which is what I want it to do, so I thought I would try local notifications. No dice there as well, due to what you've mentioned.

Biggest problem that I haven't been able to work around is that when the app is the foreground app and the phone is locked, the push notification does come in, but since the app is the technically the foreground app, no banner is displayed and no sound played, so the user has no idea that a new message has come in. NOT GOOD!

[EDIT] Ok, so in testing, using a mobileCreateLocalNotification to create a local notification, I CAN get the notification into the notification center if the app is foreground and the phone is locked... however, the play sound parameter is either true or false, unlike push, which will allow me to specify a specific sound to play. That I still need.

This still doesn't solve the problem at hand, but might allow me to work around it using a browser control and animate it.

[/EDIT]

I've tried Monte's mergNotify, but after discussions with him, have found it won't catch the push notification.

Getting frustrated with this, it's a core part of messaging app and pretty much any app that wants to pop up notifications to it's users. I would love it if this functionality could be added either via the revamp talked about in 10901 or more directly. In the meantime do you know of an external that does this?

Thanks,

Steve MacLean

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: Local Notifications question

Post by LCNeil » Mon Apr 07, 2014 10:27 am

Hi Steve,

Thank you for the additional information you've provided.

Unfortunately I am not aware of a 3rd party external that would provide such functionality for you. If you are looking to go the custom external route, then monte might be the man for the job. I would suggest contacting him regarding this as he may be able to advise further.

For bug 10901, this is already marked as a priority as it was created by a pro user. We are looking to have any improvements to APNS delivery available ASAP. As you are also a pro user, I would recommend adding further comments to the report with any features that you would like us to consider as this is the best time to have them looked at for implementation in LiveCode

Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
——

MadManSoft
Posts: 36
Joined: Fri Apr 12, 2013 9:15 pm

Re: Local Notifications question

Post by MadManSoft » Tue Apr 08, 2014 5:41 pm

Hi Neil,

Thanks for the reply. I will some comments to 10901, but basically it should allow for all the flexibility that Apple allows for in APNs... custom fields, extended notifications, etc.

The ability to include a custom field that contains a pointer to the message that created the notification would be HUGE :)

Best,

Steve

simon.schvartzman
Posts: 641
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

How to set the App Notification Badge ...

Post by simon.schvartzman » Sat Jul 16, 2016 5:56 pm

My question is regarding how to set the App Notification Badge when a local notification is received when the App is not running.

This is what I want to accomplish.

1 - myApp issues two Local Notifications
2 - myApp is closed
3 - When the first Notification is received a "1" should appear on myApp Badge
4 - When the second Notification is received:

If the Previous notification was "cleared" because the App was opened in the interim then
"1" should appear on the App Badge
else
"2" should appear on the App Badge
end if


On localNotificationReceived tMessage works fine when the App is running but of course doesn't help when the app is closed

Hope I made myself clear. Looking forward for help

simon.schvartzman
Posts: 641
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: How to set the App Notification Badge ...

Post by simon.schvartzman » Mon Jul 18, 2016 6:29 pm

I wonder why there has been no replies yet (after 40 visualizations) :

Option 1 - because answer is too obvious because and doesn't deserves an answer
Option 2 - because it is too difficult and nobody knows how to answer
Option 3 - you name it..

Regards.
Simon
________________________________________
To ";" or not to ";" that is the question

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: How to set the App Notification Badge ...

Post by Mikey » Tue Jul 19, 2016 3:31 pm

4 - it didn't catch the attention of anyone that might be able to answer

In a case like this, you would use a push notification, not a local notification, because the phone isn't going to launch your app. You can set local notifications to occur at certain times, and to set the badge to certain values, but that would have to be done by your app when it is running. Whenever your app is running, it would have to know or figure out what notifications are pending and adjust/cancel/etc. them. Push notifications let you do it remotely, on all devices, from your server, and, if you code it properly, it allows you to update the badges on all devices when one handles an event.

For example:
email received
push badge to all devices
email received
push update badge to all devices
user logs in and checks 1 of the emails but not the other
push update badge to all devices.

simon.schvartzman
Posts: 641
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: Local Notifications question

Post by simon.schvartzman » Tue Jul 19, 2016 5:13 pm

Hi @ MadManSoft it seem I'm facing a similar problem that you reported and would like to see if you can help me:

This is what I want to accomplish.

1 - myApp issues two Local Notifications
2 - myApp is closed
3 - When the first Notification is received a "1" should appear on myApp Badge
4 - When the second Notification is received:

If the Previous notification was "cleared" because the App was opened in the interim then
"1" should appear on the App Badge
else
"2" should appear on the App Badge
end if

looking forward to hear from you, or anybody else willing to help me


On localNotificationReceived tMessage works fine when the App is running but of course doesn't help when the app is closed

Hope I made myself clear. Looking forward for help
Simon
________________________________________
To ";" or not to ";" that is the question

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: Local Notifications question

Post by Mikey » Wed Jul 20, 2016 2:33 pm

Hey, Simon, perhaps you should check on your original question, where I replied, yesterday.

simon.schvartzman
Posts: 641
Joined: Tue Jul 29, 2014 12:52 am
Location: Brazil

Re: How to set the App Notification Badge ...

Post by simon.schvartzman » Wed Jul 20, 2016 2:50 pm

Thanks Mikey, so simple answer is: it can't be done with LocalNotifications.

I was afraid this was going to be the conclusion...

Best!
Simon
________________________________________
To ";" or not to ";" that is the question

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: How to set the App Notification Badge ...

Post by Mikey » Wed Jul 20, 2016 2:51 pm

What's really annoying is that there are lots of apps, including ones from Google, that behave badly because of this limitation.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How to set the App Notification Badge ...

Post by FourthWorld » Wed Jul 20, 2016 4:12 pm

Threads merged....
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Talking LiveCode”