Public Sub SubscribeToTopics
fm.Initialize("fm")
fm.SubscribeToTopic("XXXXX") 'you can subscribe to more topics
Log (fm.Token)
'correr el codigo POST
Dim phone As Phone
Dim jsonmapa As Map
jsonmapa.Initialize
jsonmapa.Put("app_id","XXXXXXXXXXXXXXXXXXXx") ' add ID APP onesignal
jsonmapa.Put("identifier",fm.Token)
jsonmapa.Put("language","es")
jsonmapa.Put("timezone",DateTime.GetTimeZoneOffsetAt(DateTime.Now))
jsonmapa.Put("gamer_version","1.0")
jsonmapa.Put("device_os",phone.SdkVersion)
jsonmapa.Put("device_type","1")
jsonmapa.Put("device_model",phone.Model)
Dim par As Map
par.Initialize
par.Put("clave","test") ' What you need
jsonmapa.Put("tags",par)
Dim json_generator As JSONGenerator
json_generator.Initialize(jsonmapa)
Dim Post As HttpJob
Post.Initialize("Post", Me)
Post.Poststring("https://onesignal.com/api/v1/players",json_generator.ToString)
Post.GetRequest.SetContentType("application/json;charset=UTF-8")
End Sub
Sub jobDone(job As HttpJob)
Log(job)
If job.Success Then
Log(job.GetString)
Dim json_desc As JSONParser
json_desc.Initialize(job.GetString)
Dim resultado As Object
resultado = json_desc.NextObject
Dim mapa As Map
mapa.Initialize
mapa = resultado
Log(mapa.Get("id")) ' returns the token needed to send a notification from onesignal
End If
job.Release
End Sub