I saw in the other thread you use preferences.clearAll(). That would pretty 
much explain your problem...

On Friday, May 21, 2021 at 7:56:25 AM UTC+3 Shai Almog wrote:

> You have this: if (!Preferences.get("setIt", false)) which indicates you 
> don't call it every time.
> However, Push.getPushKey() should work and never turn back to null unless 
> you wipe something from storage/preferences. Is there some other code that 
> encrypts, wipes, logs out etc?
> On Thursday, May 20, 2021 at 5:37:41 PM UTC+3 hana....@gmail.com wrote:
>
>> Thank you for your responses. 
>>
>> *Have you tried delaying getting the token a bit? CN1's native code does 
>> this thing where it tries to get the token once and then if not available 
>> it waits a few secs and tries again* - Thank you, I'll do that. Worth to 
>> try. 
>>
>> *You need to call register for push every time the app loads* - It does 
>> register every time, at least that what I can see from logs. The 
>> registeredForPush() method is called and it shows me the push key in the 
>> logs every time I launch the app. However, when I try to use the push key 
>> later in my code (sending it in ConnectionRequest to the backend), it 
>> doesn't work (the Push.getPushKey() is null), unless I call the  
>> registeredForPush() method again (which I do by reopening the app). 
>> I want to make sure that it's working after the first loading of the app. 
>>
>>
>>
>> On Wednesday, May 19, 2021 at 10:35:40 PM UTC-4 Shai Almog wrote:
>>
>>> You need to call register for push every time the app loads. Not just 
>>> the first time. So even if it fails the first time the app loads it should 
>>> work the second time.
>>>
>>> On Thursday, May 20, 2021 at 12:52:26 AM UTC+3 javier...@gmail.com 
>>> wrote:
>>>
>>>> (only a user like you)
>>>>
>>>> Have you tried delaying getting the token a bit? CN1's native code does 
>>>> this thing where it tries to get the token once and then if not available 
>>>> it waits a few secs and tries again
>>>>
>>>> Something along these lines: (hope I don't confuse you more than help 
>>>> you) 
>>>> https://gist.github.com/javieranton-zz/821455be02cf9e899b98f609152e99d4
>>>>
>>>> On Wed, 19 May 2021 at 22:18, Hannah R <hana....@gmail.com> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I have the following issue:
>>>>> In Android 7.0, when getting Push.getPushKey()  (not in 
>>>>> registeredForPush() method) the first time, it's null. 
>>>>> I have *callSerially(() -> registerPush());*
>>>>> in my start() method and 
>>>>> besides that, I added 
>>>>>
>>>>>
>>>>>
>>>>> *  if (!Preferences.get("setIt", false)) {        
>>>>> Display.getInstance().registerPush();        Preferences.set("setIt", 
>>>>> true);  }*
>>>>> into my pushRegistrationError(String error, int errorCode).
>>>>>
>>>>> If I kill the app, then open and call Push.getPushKey() the second 
>>>>> time, it gives me a valid id. 
>>>>>
>>>>> I put a log to test what is inside of the registeredForPush(String 
>>>>> deviceId) method, and it seems to work correctly - the *devicePush *is 
>>>>> not null and shows the id.(devicePush = Push.getPushKey();) 
>>>>>
>>>>> This happens only in Android 7, Android 10 and Android 8 devices 
>>>>> register push successfully from the first call. 
>>>>>
>>>>> 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 codenameone-discu...@googlegroups.com.
>>>>> To view this discussion on the web visit 
>>>>> https://groups.google.com/d/msgid/codenameone-discussions/537ef560-4120-4c47-8309-20d0aa2a5868n%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/codenameone-discussions/537ef560-4120-4c47-8309-20d0aa2a5868n%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 codenameone-discussions+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/5ee7c5e0-f318-43ca-86ad-f2e2acebccb5n%40googlegroups.com.

Reply via email to