iOS Question Push Notifications and UNC class conflict

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
I have an iOS app which uses push notifications to indicate when there is a new message in a chat window.

If the app is active, if the user is in the chat window, the window will refresh (downloading the new messages) and if not not in the chat window, a toast message is shown.
If the app is inactive, the OS displays the Push Notification

This all works fine.

I saw that @Erel had created a new class to support iOS user Notifications, so I decided to use this instead of the toast.

This is when I ran into problems.

MAIN module:
Private Sub Application_RemoteNotification (Message As Map, CompletionHandler As CompletionHandler)
    ReleaseLog.DoReleaseLog($"Message arrived: ${Message}"$)
End Sub

Sub Process_message (Message As Map)
    ReleaseLog.DoReleaseLog("Message arrived")
    ReleaseLog.DoReleaseLog($"Message data: ${Message}"$)
    If (Message.Size = 0) Then
        Log("Message is empty")
        If (ProcessMessage(Message)) Then

            ' These lines stop push notifications working
            Private UNC As UserNotificationCenter
            ' Original code which works
        End If
    End If
End Sub

NOTE:The ProcessMessage function checks if the chat window is open, forces a refresh and returns true, else returns false.

What happens is this:
Start the app, if you go to the chat window, then push notifications come through, and the chat window is refreshed.
Move off the chat window to anywhere else in the app, initially the User Notification is displayed. But then Application_RemoteNotification stops being called and the OS starts displaying the push notification as if the app is in the background.

Further testing reveals that you don't actually need to go to the chat window for this to happen.

It seems that calling the UserNotificationCenter code is preventing Push Notifications from being delivered.

Any Ideas?

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
But it seems strange that any push notification that comes in AFTER I have used this call no longer arrives at the app. Which means that I can no longer handle Push Notifications silently.

Is there a way to turn this behaviour off. If not I will stick with toast.
Upvote 0