Can an application forward iPhone notifications to a web server? - ios

I would like to connect it to a raspberry pi that will react via it's gpio ports everytime the iPhone receives a notification.
Is it possible to create an application that can forward all notifications arriving to an iPhone to a webserver in order to process that 'notification' data?
Thanks

https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html
Looking at this, it seems like you'd have to get the notificationn from the provider, since the APNs is a fairly closed system.

Related

How to stay connected to mqtt broker after I terminate my application (ios , Swift)

I'm developing an app in swift using this source https://github.com/aciidb0mb3r/SwiftMQTT
I want to add remote push notifications. I managed to do it with local notifications for example, when the app is running even if it's not in the foreground.
My question is how can i do it when the app isn't running. As i have seen when i close the app completed my broker say that i'm disconnected.
Is there any way to stay connected forever?
Something like remote push notifications that wake's up the application even if its not running
Thanks in advance :)
Finally I found out what it should be.
Hivemq (a mqtt broker) has a guide for developing a plugin with java, so that I did, I implemented push notification backend and with mysql connected clients and when the message comes I search offline clients with the topic of message and send only to them the push!
Thanks all for your help.
You can try using background fetch for periodical checking for messages.
Here is a useful tutorial for the different background modes ( it may be a bit outdated but the concepts are still valid ).
https://www.raywenderlich.com/143128/background-modes-tutorial-getting-started

Ping application in ios

is there any method to follow the applications on ios devices?
For instance , can I ping to ios devices on server side? or can I send silent push to device to get if application runs or not?
Thank you.
Your best bet is to let the app sending 'online' and 'offline' (combined with some unique per device id to the server) every time it gets open and closed. Then your server can store the state in some kind of database and you can read it from there if an app is currently online or offline on the client device.

How to push data from local server to iPad - No APN, No Internet Connection

Is there a way to push data from local server (hosted on intranet) to an iPad application without internet connection? The app is supposed to work only on LAN over wifi. Apple Push Notification is out of picture as internet connection is not available.
However the app will be running on both the devices all the time.
The model, I am talking about, is something like this:
Devices: Local Server - Wifi Connection - iPad1, iPad2
iPad1 updates some data on local server over wifi... Server needs to notify iPad2 about the change over Wifi.
Thank You!
This is not possible. Because if we want to deliver a notification, it will have to deliver to the APN server(which have the responsibility to send notifications to the device). So in the case of no internet connection it is impossible.
You need to use use Local Notification instead of Push Notification.May be it will helpful to you.
http://www.icodeblog.com/2010/07/29/iphone-programming-tutorial-local-notifications/

XCode iDevice app - How to listen for message/request from server?

I have a project where I need to be able to send messages from a server running a web service to a specific iDevice. I have no idea how to do this, so any help is very appreciated.
The scenario: I have a web service which receives some message from an iDevice (could also be a Mac or PC, even an Android device). Depending on the content of this message I need to be able to send a message from the web service to another iDevice (I know the IP-address of the specific iDevice). I know how to use URLRequests to send a message from an iDevice to a server and collect the response from the server. In principle I could every 10 seconds send a request to the server asking if the server has any new messages to the sender (the iDevice sending the request), but I am pretty sure this is not the correct way to do it. Is there a way to have an iDevice listen for server communication on a specific port, so that the iDevice only does something active when it receives a message from the server to do something, e.g. display a message in the app listening for the server communication?
I guess I need to use something similar to the technology used for iMessage, but how is this done?
I am using XCode 4.6.2, iOS 6.1.
EDIT: Just to clarify my needs a bit more: The APNS seems to be TOO unreliable (at least that is what I have read in other threads regarding APN) as the web service in some cases can have the need for sending 2 distinct message to an iDevice within 1 minute (in some cases seconds), and as far as I have read in other threads this will simply not be possible because of how Apple's server handles ASPNS.
The app i am developing only needs to receive messages from the server when the app is active - is there any way, not using APNs, to do this, e.g. making the app listen for communication on a specific port?
Your scenario seems pretty similar to APPLE PUSH NOTIFICATIONs (APNs).
Ideally your server side should write a code in such a way that if there is any change on server side & need to be informed to all associated devices.
Then your server should post notification Apple server which will then send a notification to all the associated devices.
Refer this link
You already have but can use this code to identify the iOS/Mac deivce
NSString *identifierString = [[NSUserDefaults standardUserDefaults] objectForKey:#"myID"];
if (!identifierString) {
CFUUIDRef identifier = CFUUIDCreate(NULL);
identifierString = (NSString*)CFUUIDCreateString(NULL, identifier);
[[NSUserDefaults standardUserDefaults] setObject:identifierString forKey:#"myID"];
}
NSLog(#"%#",identifierString);
this code works till the lifetime of the app only.
After some search I have decided not to use the APNS, because it seems like people are having all sort of experience with it. I cannot use APNS because my project needs 100 % reliability and instant communication with the server.
I have decided to use tcp communication since my project only will be used in a local network. This will obviously mean more power consumption on the iDevices, but reliability is more crucial to the project.

Is it possible to build socket connection between 2 iOS devices

Is it possible to build a socket connection between 2 iOS devices connected to the same network (Without net)?
if it's possible .. Is (CocoaAsyncSocket project) useful for me?
I just want to send a message from Device A to Device B which put the app in background .. when Device B receive the message should show notification to return the app to foreground.
It's not for the App Store, so I don't care if Apple would reject the app because of this behavior.
Yes, you can do it, and yes, CocoaAsyncSocket would be useful. If you don't have to worry about the carrier network's firewalls and filters, then you should certainly be able to build a client-server app running on two iOS devices. One opens the server socket to listen, and the other one (the client) connects, via the Wi-Fi network.
Trying searching on Google (e.g. "CocoaAsyncSocket iPhone iOS site:stackoverflow.com") or directly here on Stack Overflow.
Here's somebody who seems to have accomplished this
Another link
And a post from Robbie Hanson himself, referring you to the EchoServer projects in the github repository
EchoServer project
You may have to use a static IP address for the server device (I'm not sure how much control you have over the Wi-Fi network's configuration), or use some other mechanism for letting the two devices discover each other.

Resources