iOS Question B4i how to start at boot?

IamTrying

Active Member
Licensed User
In B4A following options when i set in my service it works

B4X:
#Region Module Attributes
  #StartAtBoot: True
  #StartCommandReturnValue: android.app.Service.START_STICKY
#End Region

In B4I, how can i do that?
 

IamTrying

Active Member
Licensed User
Well in Android i made following app module working and released as test:

- App installed
- App login submitted
- App fetch every 5 or 10 second new records from PostgreSQL in server
- If Emergency row round with urgent flag, it send notification (unlock screen, open the APP to take further actions)
- On reboot of Android device the app always has to start and run as service

In iOS i need to interpret it for iOS users in my domain.
 
Upvote 0

IamTrying

Active Member
Licensed User
@Erel: 2 problem.

1 - Push notifications = Run a server on WINDOWS, B4X.
2 - Silent push notification = Pay to use firebase = https://firebase.google.com/pricing

Is it possible to use B4X in my CentOS server or FreeBSD servers (without having to depend on Windows servers). Then i would move forward with point 1. Cause many clients of mine wont like to pay other third party FireBase Google etc.
 
Upvote 0

IamTrying

Active Member
Licensed User
@Erel:

1. Push server running with config.txt:

B4X:
#push server configuration
#http://192.168.1.32:51044/send?password=123&text=Message
#path to the keystore file. Use unix style slashes:
iPushKeystore=C:/Users/tpt/Desktop/B4I/push.keystore
#same password as the password set in B4i key settings:
iPushKeystorePassword=12345678

#change to: gateway.push.apple.com for production
iGateway=gateway.sandbox.push.apple.com
iGateWayPort=2195
#change to: feedback.push.apple.com for production
iFeedback=feedback.sandbox.push.apple.com
iFeedbackPort=2196

AndroidApiKey=AIzaSyAccccccm4KHlrD7CfgRuo

PushServerPort=51044
PushServerPassword=123

2. B4i code /run:

B4X:
'Code module
#Region  Project Attributes
    #ApplicationLabel: B4i Example
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #ProvisionFile: pushdevelopment.mobileprovision
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page
    Private Const ServerUrl As String = "http://192.168.1.32:51044"
End Sub

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
End Sub

Private Sub Application_PushToken (Success As Boolean, Token() As Byte)
    If Success Then
        Dim bc As ByteConverter
        Dim j As HttpJob
        j.Initialize("j", Me)
        j.PostString(ServerUrl & "/devicetoken", "token=" & bc.HexFromBytes(Token) & "&type=1")
    Else
        Log("Error getting token: " & LastException)
    End If
End Sub

Private Sub JobDone(j As HttpJob)
    If j.Success Then
        Log("Token uploaded successfully.")
    Else
        Log("Error uploading token")
    End If
    j.Release
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"))
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
  
End Sub

Private Sub Application_Background
  
End Sub

Output:
====

B4X:
Application_Start
Application_Pushtoken
Error getting token: <B4IExceptionWrapper: Error Domain=NSCocoaErrorDomain Code=3000 "no valid “aps-environment” entitlement string found for application" UserInfo={NSLocalizedDescription=no valid “aps-environment” entitlement string found for application}>
refreshPreferences: HangTracerEnabled: 0
refreshPreferences: HangTracerDuration: 500
refreshPreferences: ActivationLoggingEnabled: 0 ActivationLoggingTaskedOffByDA:0
Application_Active


3. Try to send message to all devices. Shows 0 devices?

UYna3Y0.png


What am i doing wrong?
 
Upvote 0

IamTrying

Active Member
Licensed User
OK - thank you.

i will open a new follow up. I like the B4X push server method. It will allow me to do independent activity (instead of depending on third party services firebase. Firebase solution i will check in other testing preparation)
 
Upvote 0
Top