I'm testing Google Play Service in iOS with TBMPSkeleton from https://github.com/playgameservices/ios-basic-samples
I did upload all APNS Certificate in Google Play Console (link) but when running game on devices, i didn't receive any notifications when having invitations or when match status changed in both development or production environment. Debugging show that game did receive APNS token successfully, i did test my certificates using php scripts from https://www.raywenderlich.com/123862/push-notifications-tutorial and sent push notifications successfully.
So what wrong with my project? Did i config something wrong? I'm using XCode 7.3.1 (7D1014), Google Play Service 5.1.1
Check the Adding Push Notifications in Your iOS Game.
It's good that you were able to download your APNS certificate. But that's just step 1. The succeeding steps are:
Step 2. Create a provisioning profile that contains push notification entitlements. To learn how to create a provisioning profile, you can refer to the Apple Developer Provisioning and Development documentation, under 'Creating and Installing the Provisioning Profile'. Make sure to drag the provisioning profile to your test device in the organizer.
Step 3. Upload the .p12 file that you created to the Google Play Developer Console. The .p12 file must be in the PKCS #12 format, and must contain only a single certificate.
Step 4. Register your app to receive push notifications after the user successfully signs-in. Add the following code in your finishedWithAuth:error handler, at the point where the user has successfully signed in to Google Play games services. This brings up the standard iOS push notifications dialog. If your game already has registered for push notifications by implementing this code elsewhere, then you don't need to add this line again.
[[UIApplication sharedApplication] registerForRemoteNotifications:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert)];
Step 5. In your appDelegate, add the following code to the callback for retrieving the push device token passed back from APNS. This device token is used for outbound push notifications, and your app must register it with the Google Play games services push service. Make sure to always register your device token through GPGManager to enable push notifications from Google Play games services. Even if the user has not signed in; the GPGmanager object will cache this token and save it until the user signs in.
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken
:(NSData *)deviceToken {
NSLog(#"Got deviceToken from APNS! %#", deviceToken);
[[GPGManager sharedInstance] registerDeviceToken:deviceToken
forEnvironment:GPGPushNotificationEnvironmentSandbox];
}
Related
I have an app which had 7,000 users subscribed on Pushwoosh. We switched from Pushwoosh to OneSignal and updated our app with OneSignal documentation. New users downloading our app are getting subscribed to our push notifications but the old ones are not getting updated.
Do we have to trigger permission to send push notification again ? Does Apple allow to do so ?
What is the workaround this ?
Notification Permissions & APNs Token
Notification permission is granted at the app level, so no matter what SDK / library is in your app it can read if the user has already accepted notifications and the APNs token.
The OneSignal iOS SDK does automatically check if permission is already granted and attempts to register for an APNs token. The OneSignal SDK will register the device with the app_id you put in your app and create a new player if it is the first time you opened the app since you added OneSignal.
APNs will return the same push token each time unless the user has fully uninstalled and reinstalled your app. However just in-case Apple were to deiced to rotate the token the OneSignal SDK does call the APNs register API to be sure.
Finding & Fixing The Issue
To find the issue I recommend the following;
Only include one push notification SDK in your app at a time, it possible for SDKs to have conflicts due to method swizzling or other possible issues.
In this case remove the Pushwoosh SDK if you using OneSignal.
Try to reproduce the issue on a test device by upgrading your app.
When testing the upgrade, I recommend enabling verbose logging in the OneSignal SDK.
OneSignal.setLogLevel(.LL_VERBOSE, visualLevel: .LL_NONE)
Also observe at this point if you are getting a user on the OneSignal dashboard.
If there was an issue getting an APNs token by the OneSignal SDK there will still be a user, they will just show as unsubscribed with details why.
This all depends on how you are getting the device push token from the user's device and sending it to OneSignal. A common mistake is to only get the device token the first time the user accepts the notification permission prompt. However, the device push token is subject to change randomly at any point in the future which can result in outdated device push tokens on the server used to send notifications.
To combat this, it is suggested to register for push notification every time the user launches the app. While this won't re-prompt them to accept notification permissions, it will fetch the device push token again. The push service you are using should then be updated with the new device token.
TL;DR: at every app launch register for a device push token and send it to your push server.
I am using firebase in my iOS project for notifications. Instead of the APNS certificates, I am using auth keys (that can be downloaded only once). Now the problem is, the auth key file that has been uploaded on Firebase is lost as it was uploaded by some other developer an year ago. Now I need that auth key file to upload on CleverTap for notifications to work but as the file is lost, I am not able to do so.
Now I can't upload a new key on firebase as the existing users might not receive notifications. What option do I have to make it work so that the existing users continue receiving the notifications and I can make CleverTap notifications work?
Clevertap push notifications config works with both Auth keys & push certificate.
If you don't have auth key, you can upload the valid push certificate to make it work.
Once the above process is done, if you initiate any push notification all your users will receive that. It does not matter whether they are new or existing users.
I'm a little confused on the difference between using Certificate based connections to the APN service verse the Device Token method.
My understanding is, when sending a push notification to an iOS device, my options are either:
A) I could have registered the APN certificate with the Application bundle, and my provider can send it to the APN service to verify I'm allowed to send notifications to devices with that Application bundle.
B) My provider could be sent a "Device Token" via the downloaded application on the device over HTTP, and when I send that Device Token to the APN service, it will know the user has allowed me to send those notifications.
My questions are:
1) If I were to use method A, how could I target certain devices to send the notifications to if I don't have a device token?
2) If I use method B, where would I receive the device token to send silent notifications if my user "Doesn't Allow" push notifications? Will
func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)
Still run and allow me to pull the deviceToken out, so I can send it via HTTP to my provider?
I've adopted a piece of software that used Certificate based Push Notifications (I think) and was unsure of how it was differentiating who to send notifications to with any deviceTokens. Once I rebuilt and redownloaded the application on my iOS device the notifications stopped working, so I assumed the certificate was no longer associated with the build.
I'm also curious as to how someone can debug notifications on a physical device. I've tried the Console app on Mac and have had little luck seeing any print statements I put in the code.
I'm still very new to iOS programming so please correct me if any of my understanding of the APN Service is wrong! Thank you very much in advance!
There are a few things to understand:
Your Company/Team's Certificate
Your App/Bundle's Provisioning profile
Your Client/User's Device Token
Your BackEnd Server
1 & 2 are bundled in your app when you upload it to App Store.
You get 3 when you ask user the permission for sending PN. [For this 2 should have the capability for remote push notifications enabled]
You give 1 & 3 to 4. [1 for establishing connection with APNS server, 3 to send PN to a specific iOS device]
So, to answer your question: You need both A & B.
For better understanding how APNS works I am attaching a reference diagram that would help to clear your concept for the same.
** If I were to use method A, how could I target certain devices to send the notifications to if I don't have a device token?**
Without Device token, you won't be able to target the iPhones or
idevices on which you want to send the push notification
if my user "Doesn't Allow" push notifications -> then you won't be able to generate PUSH DEVICE TOKEN hence in this scenario you won't be able to receive any push notification.
i am building an application that is two parts. web and mobile.
in brief i want to push a notification for the mobile user when a specific thing is received from the server.
for example, if the web user added a task for the mobile user, then: a notification on the mobile appears to inform the mobile user that there is something new in the app. (just like when using facebook)
any one can help me with implementing this?
Note: i configure my application to be apple to receive notifications and it do so.
this is how to push notification from the ios device to itself:
6.3. From the App
You can also send push notifications directly from a mobile application. Remember that you need to have enabled this feature in the Parse app's settings tab by selecting "Yes" under the heading "Client push enabled?". There are several methods that can be called to send push notifications. You can consult the full list in the iOS API documentation. Here is an example:
// Create our Installation query
PFQuery *pushQuery = [PFInstallation query];
[pushQuery whereKey:#"deviceType" equalTo:#"ios"];
// Send push notification to query
[PFPush sendPushMessageToQueryInBackground:pushQuery
withMessage:#"Hello World!"];
any one knows how this can work ?? i can not import these methods !!!
6 simple steps to delivering push notifications
1. Creating an App ID
2. Generating a Certificate Request
3. Configuring an App ID for Push Notifications
4. Make APNS certificates
5. Upload certificate to Admin panel
6. Create provision profile
Also fallow this tutorial here is good explanation.
Or If you don't have server than you can do this using iOS Push Notifications Using Parse
I have used the iOS development account for creating APNS SSL certificate for sending the push notification to an iOS device for development purpose. I can get the device token using objective c sample code in iOS device.Then I can use that device token to send push notification for that specific iOS device.
Now I am going to implement MDM and for MDM iOS Enterprise account is required. There are some questions, which I want to confirm if someone has already done.
So I want to know can I use iOS Enterprise account for creating "apns ssl certificate" for development purpose?
Can I get device token for an iOS device using the same objective C sample code, so that I can send the push notification via APNS to that specific iOS device for testing purpose?
First of all MDM push notification implementation is different than push notification for third party iOS application.
1)You have to use iOS Enterprise account for MDM push notification and there are few steps to get APNS certificate.
1.Refer MDM_Protocol and follow this link: http://www.softhinker.com/in-the-news/iosmdmvendorcsrsigning Then verify few things.
remove the passphrase from customerPrivateKey.pem using this command
openssl rsa -in customerPrivateKey.pem -out PlainKey.pem
Then merge your APNS certificate (for example CustomerCompanyName.pem) downloaded from the portal https://identity.apple.com/pushcert/ using this command
cat CustomerCompanyName.pem PlainKey.pem > PlainCert.pem
Now this PlainCert.pem file can be used in your server as APNS/MDM certificate.
2)In MDM push notification there are three keys
• PushMagic - a unique token the MDM server sends with each push request
• Token - a unique token that identifies the device to the APNS service
• UnlockToken - an escrow key used to clear the passcode on the device.
MDM push notification payload is also different than push notification payload.It should look like this:
{"aps":{},"mdm":PushMagic}
Take a look at http://urbanairship.com/ its a great service for handling push notifications and you can easily send test push notifications to any registered device.
Also this tutorial: http://mobile.tutsplus.com/tutorials/iphone/iphone-sdk_apns/ was an awesome resource for me in setting up push notifications with my app.
For your first question - yes you can. In the iOS dev site, go to provisioning portal > app ID's and enable you app for push notifications(dev or production).
1) see this answer
2) not for the MDM push token - this is sent to the MDM server during the 'check-in' procedure.