can it possible to use chat service without apns - ios

I am using message chat service in my application by service request and response. But problem is that when sender sending message to receiver end receiver did'nt get any notification about the send message.
Just tell me what is the best option to respond the notification to the receiver.
Can it possible without using apple push notification service.

Adding my answers below if someone comes later with the exact same question.
If app is in foreground and user is doing live chatting you can use any of the lightweight messaging protocol(like MQTT/XMPP) to notify about new message. In this case better to put message as a payload itself for instant messaging.
For reference you can check out sample code here how to do it with MQTT.
But you should debug why your notification is not working. There are few checkpoints I can see:
1) Check your device tokenId you are storing on your application server.(In case of APNS it should be of 64 char length).
2) Check if push notification is enabled for you application in apple developer member center.
3) Check your SSL certificate used by your application server is proper. here is the simple step by step guide to get SSL cert.
https://blog.applozic.com/get-your-apple-push-ssl-certificate-abebf1edb338#.v7xu5cn0k
4) Make sure your code signing cert type is matching with apple push SSL certificate.Like if you are signing your code with developer certificate, apple push ssl cert should be of development one (not distribution).
Hope this might help others.

APNS is not for CHAT Use XMPP or MQTT. for both you will require a server side implementation.
For XMPP you can use use XMPPFramework. and for MQTT you can use Mosquito.

first you have to seen the all properties of the push notification like token id is right or not. is your appid enable the push notification service or not.

Related

iOS Notifications are not receiving that are sent from the server

First of all may be it will be a duplicate question, but due to curiosity I have asked.
I have an application in which push notifications are used, I have prepared, created all the required things for it and at last I have checked the notifications on this link: https://pushtry.com/. All are working well. NOw the problem is that, when admin wants to send the notification from their admin panel the push notifications are not receiving in iOS device.
I have update all the necessary certificates, pem files, methods for iOS 10 etc, but I don't get received the notifictions from admin panel, as per backend, when we send notifications it shows notification send successfully and showing no error for it. I don't know whats wrong going.
Any sugesstions....
First check all the validations or verifications like certificate, pem file and other things are updated on iOS and backend side. This will ensures that nothing error or fault at both ends.
Now reinstall the app in iOS, Clear all notification ids or apns token table from database. On installing the app, you will see there are few apis token available. Now open your admin panel and test again, it will works correctly.
Firstly I want to confirm which certificate you are used for the app developer or distribution.Because there are different ways for sending the notification for both(developer or distribution). Like I am using php services at backend.When I am using developer certificate my backend developer used 'ssl://gateway.sandbox.push.apple.com:2195', $err,
and when I used distribution certificate he used
//'ssl://gateway.push.apple.com:2195', $err.
Thanks

APN push notifications for chat

I'm trying to add notifications to a private chat app that uses Firebase, unfortunately Firebase has an APN service but it must be configured and needs also a server app to manage it. I'd like to have the user notified when someone is texting him while the app is in the background. The problem is that APN (Apple Push Notifications) requires a server with a certificate and that is ok with me, but I'm looking for a way to send push notifications from an iOS device to another device, I mean device-to-device push notifications and the server has just to relay the messages as they are. In my case the APN server should only relay the messages that it receives from a source device to the destination device. I couldn't find a way to obtain that without writing sever code. I want to use pre-built existing services. Has anybody any idea on how to send push notifications from one device to another without configuring and writing server apps? I tried a workaround using the background fetch iOS feature, but the system si randomly giving my app execution time... and that means that my app could wait hours before being started by the system... so that is not a viable solution. Please help
Ok, probably what I found out could be helpful for others. Actually
what I'm looking for can be directly integrated in the app. You need a library like NWPusher (free on GitHub) which can be imported, and with just a few lines of code and the APN device token you get from the system, it is possibile to implement APN notifications... easily, but most importantly... for free.
UPDATE
Check also APNS framework on GitHub. It's written in Swift 3.0 and it supports the latest features.
You are essentially looking for a messaging / chat API to handle device-to-device communication. You might want to try Pusher or PubNub

GCM in iOS - clarification

Just wanted to conform if my understanding is correct. As per my understanding, the mechanism involved in delivering the push notification to iOS App is Server -> GCM -> APNS -> iOS App. I am an iOS developer and I know that Apple strictly never allows a server other than APNS server to send a remote notification to iOS App. So, just wanted to know whether the notification is directly pushed to the iOS App from GCM or, via APNS.
Push messages are always sent by APNS.
What services like Google Cloud Messaging or Parse.com do is facilitating the administration of push messages - eg enabling an app to switch pushon or off for an app, or group users so you can send push messages to certain user groups instead of all of them.
GCM is not involved in Push Notification in iOS.
It is carried out through APNS.
Please refer
https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html
It will clear all your doubts.
Everything will be clear if you just look at image:
Its showing complete APNS process. This is the process for iOS, no GCM included for iOS.

MDM client - server communication

After reading and searching, apple MDM client - MDM server interaction seems to be:
When Server wants do sth on devices, it sends a notify to APNS (with device token & AppID for APNS to know which devices and application need to receive notification).
APNS send notify to provided app on provided device
when receive notify from APNS, Apple-MDM-client will connect to server, get command and do the command task on devices.
My questions are:
The application that registered for APNS is my application (MY_APP, not Apple-MDM-client). That means the one which receive notification is my MY_APP. Then how Apple-MDM-client know about the notification in order to connect to MDM server?
The solution can be: MY_APP receive notification, then connect to server, get command and push received commands to Apple-MDM-client, tell Apple-MDM-client do the task. If this approach is correct, how MY_APP can communicate to Apple-MDM-client?
There must be API for that purpose but I can not find it via google...
Please take a look at my answer for your original question:
How does MDM in IOS really work?
MDM is clientless protocol. Your MY_APP is not involved in MDM protocol.
What happens is:
Your server send push notification using device token, topic and PushMagic.
This is a little bit unusual push notification, because you don't specify AppID
(Check "Structure of MDM Messages" section in the MDM documentation
This push message goes directly built-in MDM client
MDM client will go and talk to server (to get new commands)
As you can see your app isn't involved in MDM at all.
I would like to enforce Victors answer(because answers to Apple's MDM are so few on the internet)!
Again, in MDM protocol the is no application that has to subscribe to Apple's push notification service, the iOS is the client here. He will be dealing with handling the requests from APNS, but for this to happen the device must have a special kind of configuration profile installed, named an enrollment profile, which is like a normal configuration profile with two payloads in it: an MDM payload, and a Certificate payload, and thats it! After the user install is, the iOS client is ready to receive requests from APNS.

How do iOS Push Notifications work?

How do iOS "push" notifications get delivered to a particular device without that device needing to poll a server?
For example, let's say I have received a new message on Facebook. Facebook notifies Apple that my device should receive a notification as such. But how does Apple know which device/IP to push the message to?
Each device can be updated with data using their own unique device tokens. This picture explains everything . .
It was too much for me to put in a comment so.
From the documentation.
Apple Push Notification service (APNs) propagates push notifications to devices having applications registered to receive those notifications. Each device establishes an accredited and encrypted IP connection with the service and receives notifications over this persistent connection. Providers connect 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..
I suggest reading the documentation for more information and how to use and configure. It's all there.
Push Notifications
I created an infographic to explain the workflow of push notifications. Hope this is helpful.
Device does not keep polling the server for the push notifications.
To keep it simple, consider an iPhone is connected to internet. On connecting to internet iPhone establishes connection to Apple Push Notifications server this connection is open connection which means data can be thrown to iPhone from server the moment data arrives to server.
Apple does not use HTTP protocol for Push notifications but if you understand HTTP Protocol its almost a similar methodology.
http://en.wikipedia.org/wiki/Push_technology#HTTP_server_push
There is a really nice exaplanation of push notifications in this article.
In iOS, apps can’t do a lot in the background. Apps are only allowed to do limited set of activities so battery life is conserved.
But what if something interesting happens and you wish to let the user know about this, even if they’re not currently using your app?

Resources