We don't have a way to distinguish that and I'm not sure we have a way of 
making that distinction. You can check if start() was invoked recently by 
saving the time it was invoked then avoid the toastbar since the app just 
loaded. It's a bit of a hack but I'm not sure if there's a better way.

On Tuesday, May 25, 2021 at 10:03:55 PM UTC+3 [email protected] wrote:

> I faced another question about implementing Toastbar for the push 
> notification on iOS.
>
> The problem is that when the push() method is called, the display is 
> always in foreground. Therefore, when you receive the push notification 
> while the app is in background, and then click the notification - when the 
> app opens into foreground, it shows the toastbar as well. It shouldn't - 
> toastbar must be shown only if the app was in foreground at the moment of 
> receiving of push. 
> I tried checking the app state by adding Display.getInstance
> ().isMinimized() statement and I keep a value in Preferences which is set 
> to show toast when the start() method is called and not to show toast 
> when the stop() method is called. 
>
> To compare, the order of methods in Android is following:
> -> Click on push notification in the notification drawer (because the 
> preference is set to background it shows the notification) ->  
> -> App calls push() and shows me the form that I want it to show - >
> -> App calls start() and the Preference is getting set to foreground (show 
> me a toastbar in the future). 
> As a result, Android has the proper behavior when I click on the push 
> notification. 
>
> iOS logic is reversed -  when you press the notification, 
> -> App calls start(), and then
> -> App calls push() . 
> So when app gets to the push method, it always thinks that the app was 
> previously in a foreground. 
>
>
> I'll appreciate any suggestions. Thank you! 
> On Thursday, January 7, 2021 at 9:43:45 AM UTC-5 [email protected] 
> wrote:
>
>> I believe Steve just added fg local notifications on iOS. So it is now 
>> possible to show fg notifications also on iOS. Pls correct me if I am wrong
>>
>> Toastbar is great but unless users are 100% focused on the app you run 
>> the risk of losing the user's attention since it shows for a limited time
>>
>> If you instead schedule a notif the user is forced to see it/ discard it. 
>> Toastbar might be enough, just saying..
>>
>> On Thu, 7 Jan 2021, 14:12 Hannah R, <[email protected]> wrote:
>>
>>> Shai, Ok, I hear your point.
>>>
>>> Toastbar works great. Thank you. 
>>>
>>> On Wednesday, January 6, 2021 at 10:04:36 PM UTC-5 Shai Almog wrote:
>>>
>>>> Push notification works in the foreground just fine. The push() method 
>>>> callback is invoked when you're in the foreground but we don't add the 
>>>> notification to the pull down as this behavior isn't consistent across 
>>>> platforms. 
>>>>
>>>> I would suggest showing a toastbar message when a push method arrives 
>>>> and the app is in the foreground. That would reduce clutter in the hidden 
>>>> pulldown UI and would increase user interaction.
>>>>
>>>> On Wednesday, January 6, 2021 at 11:26:24 PM UTC+2 [email protected] 
>>>> wrote:
>>>>
>>>>> Is LocalNotification not supported on simulator?  Or it cannot be 
>>>>> displayed on application's foreground too? 
>>>>> Because I wrote a code but the simulator is not displaying local 
>>>>> notifications in foreground. It shows only if app is paused, same as push 
>>>>> notifications. 
>>>>>
>>>>> On Wednesday, January 6, 2021 at 2:48:02 PM UTC-5 [email protected] 
>>>>> wrote:
>>>>>
>>>>>> You're welcome
>>>>>>
>>>>>> On Wed, 6 Jan 2021, 19:43 Hannah R, <[email protected]> wrote:
>>>>>>
>>>>>>> Javier, 
>>>>>>>
>>>>>>> That sounds like a good solution. Thank you. 
>>>>>>>
>>>>>>> On Wed, Jan 6, 2021 at 2:37 PM Marisole Aromatherapy <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> Hi Hannah,
>>>>>>>>
>>>>>>>> I can only speak for myself. You can schedule a local notification 
>>>>>>>> the moment you receive a push notification in the fg. That local 
>>>>>>>> notification will then be displayed. I usually schedule it for +200ms 
>>>>>>>> from 
>>>>>>>> current time
>>>>>>>>
>>>>>>>> This way you can also add a custom action to that local notification
>>>>>>>>
>>>>>>>> Javier
>>>>>>>>
>>>>>>>>
>>>>>>>> On Wed, 6 Jan 2021, 19:32 Hannah R, <[email protected]> wrote:
>>>>>>>>
>>>>>>>>> Hi everyone,
>>>>>>>>>
>>>>>>>>> Is there a way to implement push notifications the way so it'll be 
>>>>>>>>> displayed while app is running in foreground? 
>>>>>>>>> If no, are you planning on adding this feature? 
>>>>>>>>>
>>>>>>>>> Thank you. 
>>>>>>>>>
>>>>>>>>> -- 
>>>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>>>> Groups "CodenameOne Discussions" group.
>>>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>>>> send an email to [email protected].
>>>>>>>>> To view this discussion on the web visit 
>>>>>>>>> https://groups.google.com/d/msgid/codenameone-discussions/035054cd-6c10-474d-881a-eb921f45bd98n%40googlegroups.com
>>>>>>>>>  
>>>>>>>>> <https://groups.google.com/d/msgid/codenameone-discussions/035054cd-6c10-474d-881a-eb921f45bd98n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>>> .
>>>>>>>>>
>>>>>>>> -- 
>>>>>>>> You received this message because you are subscribed to a topic in 
>>>>>>>> the Google Groups "CodenameOne Discussions" group.
>>>>>>>> To unsubscribe from this topic, visit 
>>>>>>>> https://groups.google.com/d/topic/codenameone-discussions/NwAfraohBW8/unsubscribe
>>>>>>>> .
>>>>>>>> To unsubscribe from this group and all its topics, send an email to 
>>>>>>>> [email protected].
>>>>>>>> To view this discussion on the web visit 
>>>>>>>> https://groups.google.com/d/msgid/codenameone-discussions/CAG90yJ3i2m9n-OPLxzxpogOVTrJgcmd1a_pSGO_3nks0EhZYmA%40mail.gmail.com
>>>>>>>>  
>>>>>>>> <https://groups.google.com/d/msgid/codenameone-discussions/CAG90yJ3i2m9n-OPLxzxpogOVTrJgcmd1a_pSGO_3nks0EhZYmA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>>>> .
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> -- 
>>>>>>> Regards,
>>>>>>>
>>>>>>> Hannah Ryzhuk
>>>>>>>
>>>>>>> -- 
>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>> Groups "CodenameOne Discussions" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>> send an email to [email protected].
>>>>>>>
>>>>>> To view this discussion on the web visit 
>>>>>>> https://groups.google.com/d/msgid/codenameone-discussions/CAOS_rX1BbS0g3mismbZuG1B6Lrsj30UdSAjzcmB8M%2BTnaRevbw%40mail.gmail.com
>>>>>>>  
>>>>>>> <https://groups.google.com/d/msgid/codenameone-discussions/CAOS_rX1BbS0g3mismbZuG1B6Lrsj30UdSAjzcmB8M%2BTnaRevbw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>>
>>>>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "CodenameOne Discussions" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>>
>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/codenameone-discussions/0901fedf-540b-4986-8bba-269445965baan%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/codenameone-discussions/0901fedf-540b-4986-8bba-269445965baan%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/8bd3037f-bd3b-41a5-9bd8-30311dfc5851n%40googlegroups.com.

Reply via email to