B4A Library In-App Update Library

Roger Daley

Well-Known Member
Licensed User
Longtime User

This is really great, in the past I've tried to find a way to do what your library does. Just as important was the step by step instructions on how to implement it. I have inserted it in to every app I could, except one in B4XPages, I will hold off on that one for now.

Roger
 

ArminKh1993

Active Member
i will find a solution for it
but for now i dont know if "_onactivityresult" hook is changed in b4x pages or not? maybe @Erel can help us
 
Last edited:

ArminKh1993

Active Member

samikinikar

Member
Licensed User
Longtime User
Works perfectly on given test app, but not on my app, The app updates dialog repeats every time even though the update/install is complete. When I start the app, I still see the old app. Any idea what might be the issue.
 

ArminKh1993

Active Member
Works perfectly on given test app, but not on my app, The app updates dialog repeats every time even though the update/install is complete. When I start the app, I still see the old app. Any idea what might be the issue.
As i said at first post:
  • When testing, make sure the Google Play cache is up to date by closing the Play Store App and then going back to the My Apps & Games tab before testing updates.
 

samikinikar

Member
Licensed User
Longtime User
Thank you for the update, Its the same, I tried multiple devices too, then too same issue. The update dialog repeats again and again, even after completing.
 

epneeh

Member
Thank you for the update, Its the same, I tried multiple devices too, then too same issue. The update dialog repeats again and again, even after completing.
Hi there, i have similar issues, i also check inAppUpdateInfo.availableVersionCode for version code it says lower version (61) than my latest version (63)
 

ArminKh1993

Active Member
Hi there, i have similar issues, i also check inAppUpdateInfo.availableVersionCode for version code it says lower version (61) than my latest version (63)
Please read first post.
  • When testing, make sure the Google Play cache is up to date by closing the Play Store App and then going back to the My Apps & Games tab before testing updates.
 

ArminKh1993

Active Member
I recently tried to run a project on b4xpages and used this library as well.
If you want to use this library in b4xpages, you have to change a few pieces of code.

- Define a variable as InAppUpdate library in your page.
B4X:
Private Sub Class_Globals
     Private InAppUpdate As InAppUpdate   
End Sub

- Copy this codes to your page without change.
B4X:
Private Sub CheckUpdate
    InAppUpdate.initialize(False)
    InAppUpdate.GetAppUpdateInfo
End Sub

Private Sub InAppUpdate_onAppUpdateInfoReceived(success As Boolean, inAppUpdateInfo As InAppUpdateInfo)
    Log($"InAppUpdate_onAppUpdateInfoReceived, Success: ${success}"$)

    If success Then
      If inAppUpdateInfo.updateAvailability = inAppUpdateInfo.UPDATE_AVAILABILITY_DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS Or inAppUpdateInfo.updateAvailability = inAppUpdateInfo.UPDATE_AVAILABILITY_AVAILABLE Then
        InAppUpdate.startImmediateUpdateFlow
      End If
    End If
End Sub

- Copy this codes to your main activity without change.
B4X:
Sub InAppUpdate_onUserAcceptUpdate(accepted As Boolean)
        #IF JAVA
            public void _onactivityresult(int requestCode,int resultCode){
                com.khaan.iau.InAppUpdate.onActivityResult(activityBA,requestCode,resultCode);
            }
        #END IF
        
        CallSub2(B4XPages.MainPage,"InAppUpdate_onUserAcceptUpdate",accepted)
End Sub

- Note: You must replace B4XPages.MainPage with your page

- And finaly call CheckUpdate everywhere you want. for example in B4XPage_Foreground
B4X:
Private Sub B4XPage_Foreground
        CheckUpdate
End Sub

Good Luck?
 

samikinikar

Member
Licensed User
Longtime User
Now another issue .... I changed the local VersionCode to higher than the play store, then too "InAppUpdate_onAppUpdateInfoReceived" is returned Success=True.

Play App Store version : 2
Local VersionCode : 4

Any idea what might be the issue ? I cleared the play cache and followed as indicated above but same issue continues.


Its solved now.
 
Last edited:

ArminKh1993

Active Member
Success=True means that the app information has been successfully received from the server.
 

tarique

Member
I have difficulty in this library, I have tested this library, it does not work on android 6, 9, and 11. only it is working on android 7, even on android 7 the update screen also repeats itself, it shows installation completed but the app is still old.

in android 6,9 and 11 I am getting this only "InAppUpdate_onAppUpdateInfoReceived, Success: true"
I have cleared the cache of the play store as well but the problem still exists.
 

Roger Daley

Well-Known Member
Licensed User
Longtime User

Tarique,
I can't help you much except to confirm the library works well on Android 8 &11, LG V20 & Galaxy A70 respectively.

I hope you find your problem, the update feature is really great and looks very professional.

Regards Roger.
 

tarique

Member
Than
Tarique,
I can't help you much except to confirm the library works well on Android 8 &11, LG V20 & Galaxy A70 respectively.

I hope you find your problem, the update feature is really great and looks very professional.

Regards Roger.
Thanks, but I am getting this response when I use "Inappupdatetest" example for b4xpages available on "https://www.b4x.com/android/forum/t...brary-usable-with-b4xpages.126534/post-791573" I have changed pkg name and used signing Keystore file, the available version Code on playstore is 7, while I have tested from 1 to 6 and it shows me the following response with following code

Test code:
Private Sub InAppUpdate_onAppUpdateInfoReceived(success As Boolean, inAppUpdateInfo As InAppUpdateInfo)
        Log($"InAppUpdate_onAppUpdateInfoReceived, Success: ${success}"$)
Log(inAppUpdateInfo.UPDATE_AVAILABILITY_AVAILABLE)
Log(inAppUpdateInfo.UPDATE_AVAILABILITY_DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS)
Log(inAppUpdateInfo.UPDATE_AVAILABILITY_NOT_AVAILABLE)
Log(inAppUpdateInfo.UPDATE_AVAILABILITY_UNKNOWN)
Log(inAppUpdateInfo.updateAvailability)
        If success Then
          If inAppUpdateInfo.updateAvailability = inAppUpdateInfo.UPDATE_AVAILABILITY_DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS Or inAppUpdateInfo.updateAvailability = inAppUpdateInfo.UPDATE_AVAILABILITY_AVAILABLE Then
                InAppUpdate.startImmediateUpdateFlow
          End If
        End If
End Sub

the output response of thes logs are
InAppUpdate_onAppUpdateInfoReceived, Success: true
Log(inAppUpdateInfo.UPDATE_AVAILABILITY_AVAILABLE) =2
Log(inAppUpdateInfo.UPDATE_AVAILABILITY_DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) =3
Log(inAppUpdateInfo.UPDATE_AVAILABILITY_NOT_AVAILABLE)=1
Log(inAppUpdateInfo.UPDATE_AVAILABILITY_UNKNOWN)=0
Log(inAppUpdateInfo.updateAvailability)=1
the value of Log(inAppUpdateInfo.updateAvailability) should be 2

I don't know why it shows me that there is no new version. even playstore not showing update button, it only shows open and uninstall. by pressing open button this test example opens.
 

ArminKh1993

Active Member
Unfortunately, due to the revocation of my account license, I can no longer support my libraries. It is funny that I can not even edit my messages
You can ask for help from Erel or other members in the forum or you can use other libraries.
I'm sorry for what happened and I hope you understand what I mean. Thanks
 

Roger Daley

Well-Known Member
Licensed User
Longtime User

Not really sure what you mean. But sorry to lose your contributions if that is the case.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…