mirror of
https://github.com/cheveguerra/Pusher_2.0.git
synced 2026-04-17 19:37:05 +00:00
28/9/23 - Se agregó´codigo para guardar las geocercas y recibir mensajes push.
- Se agregó la base de datos y el codigo para guardar y administrar las geocercas. - Se modificó el codigo de los mensajes push recibidos, para que mande una notificación si la ubicación recibida esta dentro de una geocerca.
This commit is contained in:
@@ -6,10 +6,12 @@ Version=10.5
|
||||
@EndOfDesignText@
|
||||
Sub Process_Globals
|
||||
Private fm As FirebaseMessaging
|
||||
Dim db As SQL
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
fm.Initialize("fm")
|
||||
db = Subs.dbInit
|
||||
End Sub
|
||||
|
||||
Public Sub SubscribeToTopics
|
||||
@@ -49,8 +51,32 @@ Sub fm_MessageArrived (Message As RemoteMessage)
|
||||
'Si el mensaje es de ubicacion recibida
|
||||
If Message.GetData.ContainsKey("t") And (Message.GetData.Get("t") = "u" Or Message.GetData.Get("t") = "au") Then
|
||||
Log("Recibimos ubicacion")
|
||||
Private ubi As Location
|
||||
Log("Llamamos UbicacionRecibida")
|
||||
If Message.GetData.Get("t") = "au" Then ToastMessageShow("Ubicacion recibida:"&Message.GetData.Get("d"),False)
|
||||
If Message.GetData.Get("t") = "au" Then
|
||||
' ToastMessageShow("Ubicacion recibida:"&Message.GetData.Get("body"),False)
|
||||
Private coords() As String = Regex.split(",", Message.GetData.Get("body"))
|
||||
ubi.Initialize
|
||||
ubi.Latitude = coords(0)
|
||||
ubi.Longitude = coords(1)
|
||||
Private c As Cursor = db.ExecQuery("select * from geocercas") 'Traemos las geocercas
|
||||
Private estaGC As Location
|
||||
If c.RowCount > 0 Then
|
||||
For i = 0 To c.RowCount - 1
|
||||
c.Position = i
|
||||
estaGC.Initialize
|
||||
estaGC.Latitude = c.GetString("lat")
|
||||
estaGC.Longitude = c.GetString("lon")
|
||||
Log(ubi & "|" & estaGC)
|
||||
Log(ubi.DistanceTo(estaGC))
|
||||
If ubi.DistanceTo(estaGC) < 300 Then 'Revisamos si la ubicaccion recibida esta dentro de alguna geocerca.
|
||||
' ToastMessageShow($"Dentro de ${c.GetString("nombre")}"$, False)
|
||||
Subs.notiHigh("Dentro de Geocerca", $"${Message.GetData.Get("d")} esta dentro de ${c.GetString("nombre")}"$, 777, "Main")
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
' Subs.notiHigh("Dentro de Geocerca", $"${Message.GetData.Get("d")} esta dentro de ${c.GetString("nombre")}"$, 777, "Main")
|
||||
End If
|
||||
CallSub2(Main, "ubicacionRecibida", Message.GetData)
|
||||
End If
|
||||
|
||||
|
||||
Reference in New Issue
Block a user