as template to send a json (string) via post to a web api i used this from within a activity.
myself did not used this onsignal service.
i believe b4a add the permissions self at usage in manifest
but you find the required permissions also in online docu from this lib.
a web request have a http header and data.
Sub Send() As Boolean
Dim Map1 As Map
Map1.Initialize
Map1.Clear
Map1.Put("ABC",1.0)
Dim JSON As JSONGenerator
JSON.Initialize(Map1)
Dim data As String = JSON.ToPrettyString(1) ' JSON.ToString()
Log(data)
Dim Job As HttpJob
Job.Initialize("Job1",Me)
Job.Username=Main.API_User
Job.Password=Main.API_Password
Job.PostString("https://xy.blah.com/abc" , data )
Job.GetRequest.SetContentType("application/json") 'need okhttp lib
Return True
End Sub
Sub JobDone(Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
Case "Job1"
Log(Job.GetString)
If Job.GetString.StartsWith(Chr(34) & "OK" & Chr(34) ) Then 'grrr
ToastMessageShow(Job.GetString,True)
StartActivity(ActivityThanks)
Activity.Finish
Else
ButtonSend.Enabled=True
ToastMessageShow("Error: " & Job.GetString, True)
End If
Case "JobTemplate"
Log(Job.GetString)
End Select
Else
ButtonSend.Enabled=True
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub