B4J Tutorial [Web] Beginning Telegram Mini Apps - Alerts

Mashiane

Expert
Licensed User
Longtime User
Request Write Access (interaction with the bot)

B4X:
Sub btnrequestwriteaccess_click (e As BANanoEvent)
    e.PreventDefault
    WA.requestWriteAccess(Me)
End Sub

Sub RequestWriteAccess (Allowed As Boolean)
    Select Case Allowed
    Case True
        app.ShowToastSuccess("Access granted!")
    Case Else
        app.ShowToastError("User declined request!")    
    End Select
End Sub
 

Mashiane

Expert
Licensed User
Longtime User
Request to share the user contact details with the bot.

B4X:
Sub btnrequestcontact_click (e As BANanoEvent)
    e.PreventDefault
    WA.requestContact(Me)
End Sub
'
Sub RequestContact (SharedContact As Boolean)
    Select Case SharedContact
    Case True
        app.ShowToastSuccess("Contact granted!")
    Case Else
        app.ShowToastError("Contact denied!")    
    End Select
End Sub
 

Mashiane

Expert
Licensed User
Longtime User
Show PopUp

B4X:
Sub btnshowpopup_click (e As BANanoEvent)
    e.PreventDefault
    '
    Dim btns As List = WA.CreateButtons
    WA.AddDestructiveButton(btns, "delete", "Delete All")
    WA.AddDefaultButton(btns, "faq", "Open FAQ")
    WA.AddCancelButton(btns)
    WA.showPopup(Me, "TMA PopUp", "Lets show this popup.", btns)
End Sub
'
Sub ShowPopup (btnID As String)
    Select Case btnID
    Case "delete"
        WA.showAlert(Me, "'Delete All' selected.")
    Case "faq"
        WA.openLink("https://telegram.org/faq")
    End Select
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…