My application sending message to android clients. My application working well before compile. But after compile cannot send message. i am not getting any error message.
I compiled my app with Packager 1.50. What can i do? Thanks.
This is my code
I compiled my app with Packager 1.50. What can i do? Thanks.
This is my code
B4X:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Dim sqlMS As SQL
Private const API_KEY As String = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
Private Label1 As Label
Dim sqlMS As SQL
Private TextArea1 As TextArea
Private CheckBox1 As CheckBox
End Sub
public Sub initialize
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
End Sub
Private Sub KayitGir
sqlMS.Initialize("com.microsoft.sqlserver.jdbc.SQLServerDriver","jdbc:sqlserver://xxxxxxxxxxx:1433;databaseName=xxxxxxx;user=xxxxxx;password=xxxxxxxx;")
sqlMS.BeginTransaction
Try
sqlMS.ExecNonQuery("INSERT INTO [haberler] ([detay], [tarih]) VALUES ('" & TextArea1.Text & "', GETDATE())")
Label1.Text = "Kayıt başarıyla girildi"
If CheckBox1.Checked Then
Dim Baslik As String = TextArea1.Text.SubString(0)
Dim Detay As String = TextArea1.Text
SendMessage("general", Baslik, Detay)
End If
Catch
Label1.Text = "Bir hata oluştu: " & LastException.Message
End Try
'sqlMS.Close
sqlMS.TransactionSuccessful
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Private Sub Button1_Click
'xui.MsgboxAsync("Hello world!", "B4X")
KayitGir
End Sub
Private Sub SendMessage(Topic As String, Title As String, Body As String)
Dim Job As HttpJob
Job.Initialize("fcm", Me)
Dim m As Map = CreateMap("to": $"/topics/${Topic}"$)
Dim data As Map = CreateMap("title": Title, "body": Body)
If Topic.StartsWith("ios_") Then
Dim iosalert As Map = CreateMap("title": Title, "body": Body, "sound": "default")
m.Put("notification", iosalert)
m.Put("priority", 10)
End If
m.Put("data", data)
Dim jg As JSONGenerator
jg.Initialize(m)
Job.PostString("https://fcm.googleapis.com/fcm/send", jg.ToString)
Job.GetRequest.SetContentType("application/json;charset=UTF-8")
Job.GetRequest.SetHeader("Authorization", "key=" & API_KEY)
End Sub
Sub JobDone(job As HttpJob)
'Log(job)
Dim Gonderildi As Boolean = False
If job.Success Then
'Log(job.GetString)
Gonderildi=True
Else
Gonderildi=False
End If
If Gonderildi Then
Label1.Text = Label1.Text & " Bildirim Gönderildi."
Else
Label1.Text = Label1.Text & " Bir hata oluştu. Bildirim gönderilemedi."
End If
job.Release
'ExitApplication '!
End Sub