I took the example code for server side (b4j) and integrated in my homemanagement. Running the b4j code on the laptop it works: i can send a notification to the app on my phone. But the same code running on the rasberry gives this message from google:
So next i filled the requested Credentials and got a ClientID for a device. But where should i store this in the example code? The projectID and the API key are there (and working as the program runs on my laptop). But how to proceed to get this working server side running on a raspberry Pi?
Someone solved this problem?
Done....
results:
Testexample working Rpi ánd PC
Same code works also in application when inserted just before startmessageloop (Rpi and pc)
B4X:
SendNotificatie("general", "this is the title", "And this is the body")
StartMessageLoop
When starting the code from a button in AMBMaterial it works on the PC, not on the Rpi.Throws the error
B4X:
Sub tbl1_Clicked(PassedRowsAndColumns As List)
Private lbl=tbl.GetString(tblCellInfo.row, 1) As String
Select Case tbl.GetString(tblCellInfo.row,0)
Select Case tbl.GetString(tblCellInfo.row,0)
Case "TestNotificatie"
Main.SendNotificatie("general","TEST!","testknop aangeklikt")
Return
end select
end sub
also tried Callsub3
B4X:
Case "TestNotificatie"
CallSub3(Main,"SendNotificatie","TEST!","testknop aangeklikt")
' Main.SendNotificatie("general","TEST!","testknop aangeklikt")
Return
solved.... in a indirect way:
timer starts the notification. Timer resides in main. One shot
Anywhere in the program the timer can started.
B4X:
public Sub StartNotification ( title As String, body As String)
NotificationTimer.Enabled=True
End Sub
private Sub NotificationTimer_tick
SendNotificatie( "this is the title", "And this is the body")
NotificationTimer.Enabled=False
End Sub
result:
{
"message": {
"data": {
"title": "this is the title",
"body": "And this is the body"
},
"android": {
"priority": "high"
},
"topic": "general"
}
}