B4J Tutorial [Web] Beginning Telegram Mini Apps - Alerts

Request Write Access (interaction with the bot)

Code:
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
 
Request to share the user contact details with the bot.

Code:
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
 
Show PopUp

Code:
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
 
Back
Top