Hi there,
I found and Created an easy way to send push notification without b4x push server
I used parse.com for my apps written with swift and I don't like b4x because It needs a power on system like vps for store device tokens
In this tutorial I use parse rest api and send device token to parse and store it
1. Register in parse.com and create an application
2. Export .p12 file from certificate using keychain in mac and upload in Parse Dashboard -> App Settings -> push -> Apple Push Certificates
3. If you want to see devices list click on Core in Dashboard and then Create a class with Installation type
4. Import ParsePush class to project (attached)
5. Add this codes to progress_globals in
6. Add this codes to application_start
7. And add subs to Main
8. Now go to push in parse dashboard and send a push notification
Unfortunately after January 28, 2017 will be disabled.
I found and Created an easy way to send push notification without b4x push server
I used parse.com for my apps written with swift and I don't like b4x because It needs a power on system like vps for store device tokens
In this tutorial I use parse rest api and send device token to parse and store it
1. Register in parse.com and create an application
2. Export .p12 file from certificate using keychain in mac and upload in Parse Dashboard -> App Settings -> push -> Apple Push Certificates
3. If you want to see devices list click on Core in Dashboard and then Create a class with Installation type
4. Import ParsePush class to project (attached)
5. Add this codes to progress_globals in
B4X:
Dim parse As ParsePush
Dim applicationId As String = "Application_ID" 'Parse Dashboard ->App Settings -> Security & Keys
Dim restApiKey As String = "REST_API_key" 'Parse Dashboard ->App Settings -> Security & Keys
6. Add this codes to application_start
B4X:
App.RegisterUserNotifications(True, True, True)
App.RegisterForRemoteNotifications
CheckForPushMessage
7. And add subs to Main
B4X:
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.Color = Colors.White
NavControl.ShowPage(Page1)
App.RegisterUserNotifications(True, True, True)
App.RegisterForRemoteNotifications
CheckForPushMessage
End Sub
Private Sub CheckForPushMessage
If App.LaunchOptions.IsInitialized And _
App.LaunchOptions.ContainsKey("UIApplicationLaunchOptionsRemoteNotificationKey") Then
Dim data As Object = App.LaunchOptions.Get("UIApplicationLaunchOptionsRemoteNotificationKey")
Dim no As NativeObject = App
no.GetField("delegate").RunMethod("application:didReceiveRemoteNotification:", _
Array(App, data))
End If
End Sub
Private Sub Application_PushToken (Success As Boolean, Token() As Byte)
If Success Then
Dim bc As ByteConverter
parse.Initialize(bc.HexFromBytes(Token),applicationId,restApiKey)
Else
Log("Error getting token: " & LastException)
End If
End Sub
Private Sub Application_RemoteNotification (Message As Map)
Log("Remote notification: " & Message)
Dim m As Map = Message.Get("aps")
Log(m)
Log(m.Get("alert"))
Msgbox("remote: " & Message, "")
End Sub
8. Now go to push in parse dashboard and send a push notification
Unfortunately after January 28, 2017 will be disabled.
Attachments
Last edited: