I want to ask you guys
How device receives push notification?
Is our device continuously connected to apple's server?
Many Thanks,
Nav
Device does not remain connected. In fact the app might not even be running any more.
The mechanism is as follows:
Your application has to register for notifications.
When it registers you get a token, which you send to your server.
When you wish to send a push notification, your server connects to Apple server and sends a message to the previously registered token.
Simple :)
For more details see:
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW9
Related
I'm trying to verify that HTTP requests from iOS application were really sent from mobile application. Currently server code just checking 'User-Agent' HTTP header and of course it's not very reliable solution.
Here is how I see current iOS SDK can be used to verify that client is an actual iPhone user.
Push notifications
iOS app requests push token from the operating system and sends it to server
Server sends push notification to application with hidden identifier
iOS app sends received identifier to server
Server responds with cookie
Here on the first stages of communication we can verify that user is mobile user because how else she got identifier from push notification to specific app.
dis. Not quite reliable even if we can repeat push notification. Misuse of push notifications.
In-App purchase
It is possible to reuse receipt verification here.
dis. Obvious misuse. Confusing.
So the question is – are there any proper ways to confirm that request was sent from iOS application, from iOS device ?
iOS11 introduces new API https://developer.apple.com/documentation/devicecheck#overview
It looks like it solves the problem.
Is it true that we can use any component for our own server component? I mean it can be a Java or C# TCP/IP client which connects with Apple servers to push notifications. This can also be a console application, is that right?
Also, is it right that we have to push notifications for APN server, with each and every deviceTokens registered on our own server?
You can use whatever language you want and you will have to send push notifications for every registered device token. You should also investigate apple's feedback API's which you should periodically check to see which of your devices are no longer registered because sending a push has no feedback and you will not know if it is being received or not. If you use a service such as Urban Airship the setup will be much much easier to start and they have helpful API's to give them a group of device tokens or to do a mass push to all registered device tokens.
You are right on both accounts. You can write your own method to send it, and you must send it to each device id.
framework that might help you:
http://www.easyapns.com/
as far as I understand APN's I can only send them to the app not a specific user that uses my app.
Is there a way of sending APN's only to specific users that use my app? I can't think of a way of doing this...
Greetz
APNS is not a broadcast medium. As it says in the documentation:
Apple Push Notification service transports and routes a notification
from a given provider to a given device.
When you send a notification from the server, one of the paramters is the device ID.
Apple's Push Notifications are always sent to specific 'users' (a specific device being an iphone, ipad)
What you do when you want to use APN is register the application for push notifications. Then you get a token that links the user's device to the notification service. You then use this token to 'push notifications' to APN which will in turn send a notification to that device. Notifications are pushed by 'Providers'.
Here's apple's documentation on the matter: Apple Push Notifications
Look up 'Registering for Remote Notifications' to register the device
and 'Handling Local and Remote Notifications' to handle the incoming notifications.
Read up on how to send notifications here: Providers
It is possible. I use Easy APNS and in newMessage() you can specify the PID (saved in a MySQL database) of the user.
Have a look at http://www.easyapns.com/
I have an iphone app receiving network message from server. It is ok when the app is running in frontend.
However, when the app is running in background, the app does not receive network message. After I bring it back to frondend, it starts receiving.
How to make the app can receive network message even it is running in background?
Thanks.
You've got two options for network connection while in the background:
Push Notifications. The app is not running, but your server can request to send a notification, which will then be sent to the iPhone, prompting the user to launch your app which can then update itself from your server thru a regular request.
Background network calls. Your app can request to keep a thread alive in the background in order to finish a network activity. You could use this to send a request when your app closes to check in with your server.
First check this post: iphone - Connecting to server in background
Second, specifically speaking, when you app is in the background and is frozen by the OS, it won't have access to the internet, thus any call back from an async request won't be heard by your app.
Third, a possible strategy:
When you app is to switch to the background, immediately post a request to your server so your server would have an updated record about your app's latest status
When your app is to switch back to the foreground, again, let your server know about this by posting a request
It might happen, that your app is still in the background while your server just need to access it or send any message to it. In this scenario, try APNs (Apple Push Notification Service) provided by Apple. It's free and easy to implement. The possible outcome once you set up APNs for your app would be, the user gets an push message from your server and then decide to put your app back to the foreground. Though it's still totally up to the user, chances are good.
I'm not an iphone dev but for me, for all background apps, all network messages should be push to apple server and then push to the phone. There is no service like in Android.
I have just heard that - " push notification " is possible in iPhone
I need following details.
what is push notification ?
How it works ?
What does it requires ?
Any sample code link is available ?
Any documentation link if available ?
Some guidance/tips from "StackOverFlow Masters" about developing the above requirements.
Thanks in advance for sharing your knowledge with Stackoverflow family & me.
The sort of background processing you're looking to do is not possible with push notification.
Push notification allows you to notify the user of something. An example would be a Twitter client that sends a notification when the user receives a direct message on Twitter.
Push notification can not react to things happening on the iPhone when the app is not running. Instead, it depends on you having a server that determines when to send a notification and then sends one.
I'm not seeing any need for background processing in your application. If you store the user's initial location, the next time the app loads you can get their location and calculate the distance between the two. If you're looking for the route travelled, you're out of luck unless you make a deal with AT&T like Loopt just did.
Push notification is not really for that purpose, you should read up on push notification in apples site here http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction/Introduction.html, its more for when theres data like a m essage for your user, you can have the user get it without having them open t he application. Now for your purpose, why cant you store the location when htey close the app, once the reopen the app you can reget a location, use the previous location and the new location to calculate the km travelled?
Although only tangentially related to this discussion, I think you might be interested in Loopt's agreement with AT&T to track user's iPhones (for a monthly fee).
Apple Push Notification service (APNs for short) is the centerpiece of the push notifications feature. It is a robust and highly efficient service for propagating information to devices such as iPhone, iPad, and iPod touch devices. Each device establishes an accredited and encrypted IP connection with the service and receives notifications over this persistent connection. If a notification for an application arrives when that application is not running, the device alerts the user that the application has data waiting for it.
Software developers (“providers”) originate the notifications in their server software. The provider connects with APNs through a persistent and secure channel while monitoring incoming data intended for their client applications. When new data for an application arrives, the provider prepares and sends a notification through the channel to APNs, which pushes the notification to the target device.
Check this link clearly explained Apple push notification services
http://mobiforge.com/developing/story/programming-apple-push-notification-services