I want to send push notification without any APNS server and device token,like android there is NO local and push notifications but they can send device to device with out google permissions.
You can NOT send a push notification without using APNs. Why? first you need to understand how the technology works:
You need a certificate for a handshake.
You need a device token to be identified by APNs.
In your app, you have to register to APNs.
The app requests the certificate from APNs (handshake).
The server sends back its certificate.
The app will establish a connection to the server and send the PN certificate to the APN server.
The server will validate that you are a trusted app.
The app requests to create a token.
The server creates a token and sends it back.
In your app you save the token (to do e.g. push notifications to a specific user instead of a broadcast).
End.
So, as you see, you need to establish a trusted connection, the APNs is responsible for creating a token to identify your device within the network, and will be responsible for sending notifications.
For more info you could see:
Apple PNs
Related
When using phonegap-plugin-push, we are creating a mobile application that uses GCM to send out push notifications to the mobile devices. We are able to push to Android devices correctly using GCM. The plugin gives us both the GCM and APNS registration tokens. When we use the GCM token to push to the APNS we are unable to push to the iOS device, however when we test the APNS token directly, we are able to push the notification. When using the GCM token and a test service we receive a "success" message, but no notification makes it to the device. We know that the device token is correct as we can send a notification directly using an online APNS push service. We have created all the certificates, we have development and production certificates.
As we receive a registration token from the GCM service using the device token and APNS token, I believe the problem lies within the communication between GCM and the device itself. As we are not receiving the notification to the device using GCM, but we are able to use the APNS token generated on registration to directly push to the device. The GCM with the registration token, will not push to device.
This link here describes the problem https://github.com/phonegap/phonegap-plugin-push/issues/532
There might be some problem with your provisional profile.
This tutorial might help you.
https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjr__OblLTNAhWHkpQKHT6MBUgQFggeMAA&url=https%3A%2F%2Fwww.raywenderlich.com%2F123862%2Fpush-notifications-tutorial&usg=AFQjCNFaM0baTw-x3Swz12MwCPu5XqEtLA&sig2=6wIOeDF8AvtCQfrheM2FXw
How can i set apple push notification when i connect to sub1.domain.com my server will send messages for that APP_ID, and when connect to sub2.domain.com i will receive messages only from that subdomain.
Like in GCM, i have 5 apps for 5 subdomains and my ios app connect to another app_id and get token for that app(subdomain).
Is that possible in apple push notifications?
iOS remote push notification just requests a device token, and APNs just send message to device via device token. The device token is unique to iDevice.
For your purpose, you can save both device token and a "token channel" to database, e.g. INSERT INTO device_tokens (channel, token) VALUES ('subdomain1', 'xxxxxxxxx'), when sending message, queue device token with channel, e.g. SELECT token FROM device_tokens WHERE channel = 'subdomain1'
The apple documentation mentions there is no restriction on multiple provider notifications servers to send push notification to iOS devices.
Is it possible, the same device token can be used in two different provider servers deployed in 2 different network,to send push notifications to same app at any moment.
Will Apple APNS, allow 2 different provider servers, use same device key to send notification from each to same app in one device?
Yes you can have multiple Gateways (SNS, Urban Airship, PushIO, etc.) connected to one platform provider (APNS, GCM, Amazon, etc.), the most important thing is the token/registration ID (specific to a device and an Application) and the certificate if you are using APNS.
Many people ask how the feedback sent by the platform provider is handled in this case.
Since feedback is idempotent, it should work without problem for different gateways; tokens saved on each Gateway can be handled in the backend application. If for example APNS sends a feedback to SNS saying that an endpoint is no longer valid (maybe because the user has uninstalled the Application), the token can directly be updated/removed from all the other Gateways. You can also leave it as it is and wait for the feedback sent by APNS to other gateways when they send notifications to the endpoint, and then update your endpoints list accordingly in those gateways.
The most important thing to note here is that feedback is idempotent, if SNS sends a push notification to an endpoint and receive a feedback, another gateway that sends a push notification to the same token will receive the same feedback.
This is my experience while working with APNS, this is like a checklist, before you start testing notification in any environment,
Certificates will decide server can connect to APN or not.
According to the certificate you have for ex. dev certificate or production
certificate, point to respective APNS sandbox.
Production Sandbox:-
Hostname: gateway.push.apple.com ,
Port: 2195
Development environment:-
Hostname: gateway.sandbox.push.apple.com ,
Port: 2195
There is no restriction that production certificate can be used in only one server or in only one network. The same production certificate can be used in multiple boxes or multiple networks to send notification to same app on a device.
Most important is checking Firewall is blocking connectivity from your network to APNS Dev or Production. So do a telnet to both production and dev environment APNS. The connection should not be blocked.
If firewall is blocking connectivity to APNS, the server code will throw "Connection Refused" or "Connection Closed" exception while sending push notification.
This is the most weird behavior I saw with APNS and certificate, because of which I lost 2-3 days. I experienced below depending upon the case,
Server is pointing to APNS Dev environment, certificate is
"Production", while sending notification to APNS, SOMETIMES
server will throw "Socket Closed Exception".
Server is pointing to APNS Dev environment, certificate is "Production", while sending notification to APNS, server logs says
notification sent to APNS, but device will not receive the
notification.
:) If you have done wrong configurations, you should be lucky to get "Socket Closed Exception".
If all the configurations are correct(for ex credentials, firewall), correct certificate and pointing to right APNS environment, the device will defiantly get a push notification. Push notification will work like a charm. It will be instant .
Hope this checklist will help in your implementation and sanity checks.
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.
iOS Device Token for the push notification is an opaque identifier of a device.
The provider can't get any device related information from the device token.
Based on Apple Push Notification programming guide, the provider needs to provide device token and payload to APNs server for the push notification.
Can provider send phone number OR bundle id OR advertising identifier OR vendor identifier to the APNs Server when the provider send token and payload to APNs server during push notification ?
So, the APNs server will not send the message to device if the device token is not associated with any device properties (like phone number or advertising identifier or vendor id).
I think you answered your own question:
Based on Apple Push Notification programming guide, the provider needs to provide device token and payload to APNs server for the push notification.
If you could provide the phone number, for example, you could simply use harvested phone numbers and spam people with push notifications. The token is not only for identifying the phone; you only get one if the user explicitly said "Yes, I want push notifications."
The only properties that determine if a push notification is delivered to an iOS application on a given device are the push certificate used to establish the connection with APNS (which determines the destination application) and the device token (which determines the destination device). Any other parameters you choose to include in your payload will have no effect on the delivery of the message.
The solution that we implemented (and it works very well), is:
have the device token sent to the server upon registration
server stores that in a 'user_device' table (which ties the user to the device - once you get the info.... at this time you only have the token, so the userId is 0)
the user continues with their login info.....
as the user completes their login (going to the server for verification), include the token and match that up in the database (note that you could also just send it at this point, but we like to send the token in #2 so we could see how many people register devices but not log in...)
Now, you have a match-up from the user data to their deviceId and can then match up various USER properties (or even the device properties if you have gotten them from other means - like when the user signed in and completed their profile) and send the appropriate push notice.