iOS Question Failure to receive Push Notifications

netkomm

Active Member
Licensed User
Longtime User
The setup I am using is the following:

The app is running the basic code seen in various posts.

B4X:
#Region  Project Attributes
    #ApplicationLabel: Push Demo
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #CertificateFile: ios_development.cer
    #ProvisionFile: XXXX.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 tokenid, BoardUrl,DeviceBoardPassword As String
    Private TextField1 As TextField
    Private Button1 As Button
End Sub

Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Register Form"
    Page1.RootPanel.LoadLayout("main")
    NavControl.ShowPage(Page1)
    App.RegisterUserNotifications(True, True, True)
    App.RegisterForRemoteNotifications
   
    CheckForPushMessage
    BoardUrl = "https://XXXXXXXXXXX/savedevice.php"
    DeviceBoardPassword = "XXXXXXXXXXXX"
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
        tokenid=bc.HexFromBytes(Token)
        Log("TOKEN = " & tokenid)
    Else
        Log("Error getting token: " & LastException)
    End If
End Sub

Private Sub JobDone(j As HttpJob)
    If j.Success Then
        If j.JobName="RegisterTask" Then
            Msgbox("Registered", "Push Demo")
        Else if j.JobName="UnRegisterTask" Then
            Msgbox("UnRegistered", "Push Demo")
        End If
    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.Get("alert"))
End Sub

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

Private Sub Application_Background
   
End Sub

Sub Button1_Click
    Dim j As HttpJob
    j.Initialize("RegisterTask", Me)
    j.Download2(BoardUrl, Array As String("device_password", DeviceBoardPassword, "name", TextField1.Text, "id", tokenid, "devicetype", "2"))
End Sub

Sub Button2_Click
    Dim j As HttpJob
    j.Initialize("UnRegisterTask", Me)
    j.Download2(BoardUrl, Array As String("device_password", DeviceBoardPassword, "name", TextField1.Text, "id", "", "devicetype", "2"))
End Sub

This same exact code was working before (up until Apple certificate expired) and I had to go through the pain of renewing everything. All the certificates seem to be ok: the app can install and the server (and also various other apps I use to test) return the following log from the apple servers

B4X:
2016-03-07 14:19:16 +0000: loaded document aps.cer
2016-03-07 14:19:19 +0000: Connected to server gateway.sandbox.push.apple.com
2016-03-07 14:19:19 +0000: Set SSL connection
2016-03-07 14:19:19 +0000: Set peer domain name gateway.sandbox.push.apple.com
2016-03-07 14:19:19 +0000: Keychain Opened 
2016-03-07 14:19:19 +0000: Certificate  data  for Apple Push Services: XXX.XXXXX.XXXX initialized successfully
2016-03-07 14:19:19 +0000: Sec Identity created
2016-03-07 14:19:19 +0000: Client certificate created
2016-03-07 14:19:26 +0000: Connected
2016-03-07 14:19:26 +0000: Token: <0a50ad78 6f4577d4 141f6b10 7c91f90c 2cc35465 14505a98 f5220a3d 2c784bdc>
2016-03-07 14:19:26 +0000: Written 92 bytes sending data to gateway.sandbox.push.apple.com:2195
2016-03-07 14:19:26 +0000: Disconnected from server gateway.sandbox.push.apple.com:2195

In the end, however, no notification is received by the phone.

The certificate I am using is the "Apple Push Notification Services SSL (Sandbox & Production)" and not the "Apple Push Notification service SSL (Sandbox)"

Any help is greatly appreciated ;)
 

netkomm

Active Member
Licensed User
Longtime User
no. I cannot use it. I need to use a PHP solution - that was working up to some time back.

To note I also used other desktop apps that use directly the certs and connect to the APN servers.

In both cases I have the same results: OK, message sent, but not received.
 
Upvote 0

netkomm

Active Member
Licensed User
Longtime User
I tried but I had way to many error to get it working and I am forced to use PHP since my client hosting won't allow to run java. :(
 
Upvote 0
Top