Retrieve and save all Apple Push Notification Device Tokens in our server for APNS? - iphone

Am trying to integrate Apple Push Notification in my app. I have studied the Apple Document and other tutorials for my understanding. But, still i have a doubt to create a server and store all Apple Push Notification devicetokens in the database. Am not going to work on Server side but, i need to explain the approach to my client. I need to understand to create a APNS server provider and save all the apple push notification device tokens and retrieve all devicetoken and retrieve a single devicetoken to send notificaions. Can you please suggest me any sample code to save all apn devicetokens and retrieve from the server? I suggest my client to create a server in C#.net platform is this correct? Thanks in advance.

Essentially, you just need to decide on a way for your app to let your servers know the device tokens. So, there are many ways to achieve this.
If your server side already involves a website, the easiest way would be to use HTTPS to do a POST request from your app. Then, the server-side code can be written as if it is handling form request from browsers. I can't really give you sample code since I don't know any C#, but this should be familiar to any web developer.

Related

Is it possible to create Custom Push Notifications with a REST service backed server?

I have an OpenEdge database, I have created a REST Service and am able to CRUD to it from the outside World.
I have created a Nativescript app that can pull data from the REST service etc, but now i want Push notifications.
I know about the Progress Kinvey backend, and Firebase backend with their push notification features but i don't want to use them.
is there a way to create my own Push notifications on my REST server etc?
So first I would like you to understand how Push Notification works just to make sure we are on same page,
Once your app is installed, you can query for a unique token and save it in your backend for future use. Whenever you want to send a push notification, you have communicate with APNs (Apple Push Notification Server) / FCM (Firebase Cloud Messaging) in order to send a push notification to your iOS / Android device using the unique token you acquired earlier.
So now you must use Firebase as that is the only way you can communicate with Android, yet you may choose to communicate with APNs yourself. But in my opinion, it will be a overhead for you as both have their own protocols, you will have to distinguish your tokens between iOS & Android, use appropriate protocols etc.,
I would suggest you to go with just Firebase plugin (until you are super familiar with APNs already), so you don't have to worry which platform the token belongs to, update / revoke invalid tokens over time etc., FCM has pretty decent APIs & Documentation that can make your life easy here.
i strongly recommend you to see my answer here answer here.
from it:
when you want to pull anything from place_1(e.g. api) to place_2(e.g. browser_client) you most have an identifier of the
place_1_resource (which commonly is the uniform-resource-locator of
api)
when you want to push anything from place_1(e.g. notification_central_server) to place_2(cellphone_client) you most
have an identifier of the place_2_resource
if you don't have any identifier for a cellphone which you want to
send it a notification, your server dont know where to send that
notification so we need a resource_identifier_like for cellphones
which is actually a device_token_like and you have just one approach
to get this device_token_like and that is the FCM/APNS

How to get the latest version information using APS

I am developing one application.In that i want to get the latest version of my app information using Apple Push Notifications.So please tell me how to do this one.I seen in some posts,in that they mension like configure the APNS in apple site and send abinary information to apple service provider.Is it sufficient to get the latest version information.
You will need to create your own server, to store the identifiers for your users. With this, you can then send notifications to users who have allowed notifications from your app.
Doing this can be quite complicated, so you may want to use a service such as Urban Airship who will provide the server, and instructions on how to implement APNS in your app.
With this done, it can be quite simple to send a push notification to your users from their website.

Understanding details of Apple Push Notification Service

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/

Clean unused tokens of Apple Push Notification on server-side

I have my own server to implement Apple Push Notification. The implementation is:
my server store APNS tokens of user in a table
whenever there's a new pushing, it's retrieve tokens from that table, then push.
Pushing is OK. But I have a confused issue: If the user turn off the APNS setting, how does my server know that, so it don't need to push to that token?
Please help me. Thank you.
You should check periodically if a token is stil valid. You can use the Apple APNS feedback service.
Regarding your query about comprehensive sample code in PHP for communicating with the APNS Feedback Service, searching on Google for "apns feedback php" returns several pages that explain how to do this... The first few pages that show up in the results actually contain code samples you might find useful, as well as a project that might be what you are looking for (http://code.google.com/p/apns-php/).

do i need to maintain a database for using push notification on my web server?

how we can maintain push notification for hundreds of devices? do we need to maintain a database on server or apple will maintain this,we just need to send payload.also i'm confusing in this matter that how do i cancel already sent payload...does someone knows about it?
You need to maintain your own database. The payload that you send to Apple includes the device token of the iphone you are sending the message to. Your table could contain as simple as an id for the user (auto-generated id, or email, or whatever you need), mapped to the iphone deviceToken, along with other columns and tables that you need for your book-keeping. The device token can be stored as String for simplicity, but it's really a 32-byte BLOB.
Once you send a payload, you cannot cancel or check its status. Once you send it, it's out of your hands.
I'd head on over to Urban Airship and play around with their implementation of Apple Push Notifications. They have a sample PHP application you can extend to fit your need and great step-by-step documentation on how to get your sample application up and running.
No, there is no way of canceling sent payload.