user1151028
user1151028

Reputation: 21

Customizing push notification

Can I have a push notification from APNS which does not contain any badge,alert or sound but app will be notified.

For MDM server the 3rd party server used to wake up the device via APNS. But there is no alert to the user like badge, alert or sound. So how to achieve it.

Please suggest.

Upvotes: 2

Views: 416

Answers (2)

Brian Willis
Brian Willis

Reputation: 23854

Except under a handful of very specific circumstances, apps aren't allowed to run in the background on iOS. Even if you do send a notification that isn't a badge/sound/alert your app wouldn't be able to do anything with it unless it was already running.

So no, it's not possible.

Upvotes: 0

Richard J. Ross III
Richard J. Ross III

Reputation: 55533

It's doable using MobileSubstrate and a jailbroken app, and creating a socket to your server. I have a sockets class available for download, here.

Here is a reference to how to create a mobile substrate addon, which you can use for reference.

Code:

extern "C" void ExampleHookInitialize() {
    Socket *socketToServer = [Socket boundTCPSocketWithAddress:[SocketAddress addressWithPort:SOME_PORT domain:DOMAIN_INET ip:SOME_IP] error:NULL];
    [socketToServer connect:[SocketAddress addressWithPort:SERVER_PORT domain:DOMAIN_INET ip:IP_OF_MY_SERVER]];

    while (true)
    {
         // reads the first 1024 bytes (1 KB) to socketData
         NSData *socketData = [socketToServer read:1024];

         // do something with data
    }
}

Note that this may be better done on separate thread, and my sockets library was compiled with ARC.

Upvotes: 1

Related Questions