IOS / Swift: receiving callbacks from a streaming service without push notifications when the application is in the background

Background Information:

I am writing an application that uses the PubNub infrastructure to directly connect one raspberry Pi with one iPhone for each individual user. The Raspberry Pi uses Arduino as a slave to collect analog data, and then uses the PubNub network to publish this data on the same iPhone, which is on the same channel. With the data that the iPhone receives, it determines (locally) if the user should be warned. Then, when the user receives a warning, they have the opportunity to configure the current state of the Raspberry Pi, sending the data (settings) back to Pi, after which they will fix the problem that requires notifying the user.

Problem:

When the iPhone application goes into the background, messages sent by the Raspberry Pi that the iPhone should receive will no longer be picked up by the application, and therefore the user will no longer be notified when they need it. The first obvious solution would be to move the logic of what guarantees the Raspberry Pi notification so that it can use Apple Push Notifications to send these alerts to the user. However, the problem is that I am also trying to track whether the connection time of the Raspberry Pi was a timeout, so if any unexpected shutdown occurs, the user is also notified of this problem. This logic, obviously, cannot be on the raspberry Pi itself, because if a shutdown occurs, it will not be able to send a notification to the iPhone itself.Having an average person server to monitor the status of the device will look like a logical solution ... however, II do n’t want anything but the iPhone and Raspberry Pi involved in the transfer and processing of data, which is clearly the main motivation for using PubNub in the first place (as part of my application).

This is not a PubNub issue. I only quote them to paint a clearer picture. It’s also worth noting that I don’t want to fake the location service so that iOS provides continuous background permissions. This is a lazy and messy solution with undesirable overhead.

Question:

( ) 15-30 , , . . , , " ". . , , , . , .

- .

+1
1

@JonW , TL; DR:). : push- . PubNub Presence Webhooks. @Paulw11 , - , PubNub BLOCKS .

Apple Silent Push Notifications

, RPi, push- ( , ). push-msg push-. :

, iOS .

... , aps ,

, , , PubNub aps.

{
    "pn_apns": {
        "aps": {
            "content-available": 1,
            "data": {
                "temperature": "55",
                "humidity": "42%"
            }
        }
    },
    "data": {
        "info": "This is the full realtime message.",
        "temperature": "55",
        "humidity": "42%"
    }
}

. push- , kill. , - , . ( , "" ) , , , .

- . , @Paulw11, push- 30 - . , push- iPhone, .

- PubNub

, RPi . RPi - ( leave) ( timeout), POST ed REST ( PubNub). - , iPhone ( push- ), .

PubNub BLOCKS - ( , !)

, , . PubNub BLOCKS - PubNub.

, JavaScript , , push- , .

, , . , , , , push-. iPhone , RPi, 30 , , Apple.

+2

Source: https://habr.com/ru/post/1609721/


All Articles