Start a new topic
Answered

iOS push notification setup not accepting my certificate

I want to set up my app for push notification and am following the respective guide. 


After exporting my .p12 file from the keychain certificate, valid for Distribution and until next year, I am trying to upload it to kinvey after clicking the configure push button. When uploading I get the message "There was an internal server error when processing your push configuration." and a message in a pop-up window saying among others: "you provided a certificate of type OTHER which cannot be used to create an application of type iOS Production...." (details see screenshot). 

I have no idea why kinvey thinks it's not a production certificate... 


Anyone can help? I checked the forum but could not see anything with the same problem...

png
(6.58 MB)

Best Answer

Hello Arnold,


Please follow the instructions given on this link generating .12 certificates and let me know if it works or not. Few questions for you:

  1. For which app you are facing this issue "Expense Reporter - Tutorial App" or "BizVocabularyBuilder"?
  2. If my suggested link doesn't help then can you please elaborate the steps you followed to generate  .p12 certificate?


I generated a new .p12 certificate for development from scratch. Uploaded it on Kinvey console Push configuration and it was accepted successfully. Steps included:

  1. Creating a CSR from the Keychain Access
  2. Generating and downloading a new APNS development certificate from my Apple Developer account
  3. Converting the .cer file to a .p12 certificate.




Thanks,

Pranav

Kinvey


hmm... I am back to square one. I could upload an p12 file before and spent the last two weeks implementing the push notification reaction and handling in the app. When I use pusher (https://github.com/noodlewerk/NWPusher) I can get the notification on my device, handle it and it works fine.


Using the Kinvey console I can make no headway. My app is already published without push notification service and my plan is to add push notification functionality in the next app version. As the app is already published but without push notification code, what certificate do I create and upload to Kinvey? 

The 

Development ios App Development or

Development Apple Push Notification service SSL or the

Production App Store and Ad Hoc or the

Production Apple Push Notification service SSL

?


I revoked all old certificates and re-issued all four newly. Then tried to upload the different certificates but for all I get the original error message again:

"There was an internal server error when processing your push configuration." and sometimes a message in a pop-up window saying among others: "you provided a certificate of type OTHER which cannot be used to create an application of type iOS Production...."

Sometimes then Kinvey accepts a certificate but when I write a message and push it over the console, nothing arrives at the device. 


Arnold,


Please check this link for all detailed instructions on how to enable push notifications on Production app. Since you are planning to add 'Push Notifications' functionality in the next version of your app, you will have to setup your app code accordingly as per this link.


Go to https://developer.apple.com/account/ios/identifier/bundle and click on your app id. In the Application services, find 'Push Notifications'. Please confirm if "Push Notifications" are enabled or not.


Thanks,

Pranav

Kinvey

Dear Pranav,

thank you for the two links. I had discovered both before already and implemented. The code in my app is in line with the link and push is enabled for developing and production mode, see screenshot attached. 

I can add the code from my appdelegate, if you think that helps. Need to erase some other parts of the code, so please let me know whether you need it or whether you have some other ideas to fix the problem.

Very grateful for your support and your quick replies!

Best, 

Arnold

Dear Pranav,


As stated before, the push notifications are enabled (green) for the app id in the development and production row. 


I also implemented the code in the links you sent, had done this over the last weeks and when using the pusher notification app, it works fine. 


I added the code from my app delegate with “…” commenting out sensitive parts. Does this help you?


I think the issue is what p12 file to use from the four certificate p12 files available. My app was published and is available on the App Store without any push notification service. Now I am additionally implementing it and trying to test it. So, can you advise which of the following certificates (respective p12 file) I should upload to Kinvey?


Development ios App Development or

Development Apple Push Notification service SSL or the

Production App Store and Ad Hoc or the

Production Apple Push Notification service SSL



Currently I uploaded the p12 file for Development Apple Push Notification service SSL. When sending a push notification through the console, I get the 202 Accepted notice but the message never arrives at the device.


Code from app delegate:


   

import UIKit
import Kinvey
…
import UserNotifications

@UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {

 var window: UIWindow?
 let userDefaults:UserDefaults = UserDefaults.standard

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

 // Override point for customization after application launch.
 //UserNotificationCenter to handle push notifications

 UNUserNotificationCenter.current().delegate = self

//basic to establish connection to kinvey
 Kinvey.sharedClient.userType = BVBUser.self
 Kinvey.sharedClient.initialize(
 appKey: “…”,
 appSecret: “…”
 )

 if launchedBefore{
 //retrieve username and password from userdefaults
 userName = userDefaults.string(forKey: Constants.UserDefaultsKeys.username)!
 userPassword = userDefaults.string(forKey: Constants.UserDefaultsKeys.userPassword)!
 loginKinveyUser(username: userName, password: userPassword)
 }else{
 //create new username and password and save it to userdefaults
 userName = UUID().uuidString
 userPassword = “…”
 signUpKinveyUser(username: userName, password: userPassword)
 loginKinveyUser(username: userName, password: userPassword)
 userDefaults.set(true, forKey: Constants.UserDefaultsKeys.launchedBefore)
 writeDefaultValuesForUserObjectToUserDefaults(username: userName, userpassword: userPassword)
 …
 }

 let completionHandler = { (result: Result<Bool, Swift.Error>) in
 switch result {
 case .success(let succeed):
 print("succeed: \(succeed)")
 case .failure(let error):
 print("error: \(error)")
 }
 }

 if #available(iOS 10.0, *) {
 Kinvey.sharedClient.push.registerForNotifications(options: nil, completionHandler: completionHandler)
 } else {
 Kinvey.sharedClient.push.registerForPush(completionHandler: completionHandler)
 }

 …

 return true
 }

 func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
 // Push Notification handling code should be performed here
 UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) {
 (granted, error) in
 print("Permission granted: \(granted)")
 guard granted else { return }
 self.getNotificationSettings()
 }
 Kinvey.sharedClient.push.badgeNumber = 100 //sets to badge 100
 }

 @available(iOS 10.0, *)
 func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
 //how to get only the message body...
 print("the new response is:")
 print(response.notification.request.content.userInfo)
 let payloadInfo = response.notification.request.content.body
 print(payloadInfo)
 //save payload to some userdefaults
//add a "new" marker to userdefault
userDefaults.set(payloadInfo, forKey: Constants.PushNotification.newPushNotificationMessage)
userDefaults.set(true, forKey: Constants.PushNotification.newPushNotificationMessageIsAvailable)
userDefaults.synchronize()

if response.actionIdentifier == UNNotificationDismissActionIdentifier {
 // The user dismissed the notification without taking action
 Kinvey.sharedClient.push.resetBadgeNumber()
 }
else if response.actionIdentifier == UNNotificationDefaultActionIdentifier {

 // The user launched the app
 Kinvey.sharedClient.push.resetBadgeNumber()
}
 }

 func getNotificationSettings() {
 UNUserNotificationCenter.current().getNotificationSettings { (settings) in
 print("Notification settings: \(settings)")
 guard settings.authorizationStatus == .authorized else { return }
 UIApplication.shared.registerForRemoteNotifications()
 }
 }

 func application(_ application: UIApplication,
 didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
 let tokenParts = deviceToken.map { data -> String in
 return String(format: "%02.2hhx", data)
 }
 let token = tokenParts.joined()
 print("Device Token: \(token)")
 }

 func application(_ application: UIApplication,
 didFailToRegisterForRemoteNotificationsWithError error: Swift.Error) {
 print("Failed to register: \(error)")
 }

 // MARK: Kinvey
 func signUpKinveyUser(username: String, password: String){
 // Create a new user with the username and the passwordset above
 User.signup(username: username, password: password) { user, error in
            if let user = user {
 //user is created
 } else {
 //there was an error with the create
 print("error message on user login: \(String(describing: error?.localizedDescription))")
 }
 }
 }

 func loginKinveyUser(username: String, password: String){
//user login, one time is enough, user credentials are cached in the app
 User.login(username: username, password: password) { user, error in
 if let user = user {
 //the log-in was successful and the user is now the active user and credentials saved
 //hide log-in view and show main app content
 print("User: \(user)")
 } else if let error = error as NSError? {
 //there was an error with the update save
 let message = error.localizedDescription
 print("error message on user login: \(String(describing: message))")
 }
 }
 }
}

 

   

Hello Arnold,


When you create the .p12 certificate you must create a Production .p12 certificate if the app is to be a Production app.


Can you attach a screenshot of the push configuration page so that we can see the values that you are entering into the push configuration screen fields? Perhaps that will tell us something.


Regards,


Billy Gee

Arnold,


You will have to use "Apple Push Notification service SSL (Sandbox & Production)" when uploading .p12 certificate to Kinvey.


Thanks,

Pranav

Dear Pranav, 

thank you for hanging in there. 

I recreated the respective certificate and p12 file. Even set the password to empty, just in case this was causing a problem.

The new p12 file was accepted by the kinvey console and I could upload it. Sending a message through the kinvey push console however resulted in the same behavior - accepted 202 message at the console but nothing showing up on my device.

Any ideas?

Arnold

Answer

Hello Arnold,


Please follow the instructions given on this link generating .12 certificates and let me know if it works or not. Few questions for you:

  1. For which app you are facing this issue "Expense Reporter - Tutorial App" or "BizVocabularyBuilder"?
  2. If my suggested link doesn't help then can you please elaborate the steps you followed to generate  .p12 certificate?


I generated a new .p12 certificate for development from scratch. Uploaded it on Kinvey console Push configuration and it was accepted successfully. Steps included:

  1. Creating a CSR from the Keychain Access
  2. Generating and downloading a new APNS development certificate from my Apple Developer account
  3. Converting the .cer file to a .p12 certificate.




Thanks,

Pranav

Kinvey

Dear Pranav, 

thank you for the step by step instructions. The error message disappeared and I could upload my newly created p12 file. 

I will try to implement push in the next few days and hope it works. 

Best, 

Arnold

Arnold,


That's a great news. Glad to hear that. Let me know if you face any issues while implementing push.


Thanks,

Pranav

Kinvey

ok, seems to work now. 

just some notes for people having similar problems. 


When you add push notification functionality at a later stage of your app, that is, your prior version (aka version 1.0) is already being sold and distributed through itunes, use the Apple Push Notification service SSL (Sandbox & Production) as the p12 file to upload to the kinvey console AND note that the push messages sent through the console will then only be received by users who download the new version - so far so clear. 


However, and that's what I didn't know, it will NOT show on your iphone that you use for developing and trying solutions; aka the iphone you hook up to xcode. 

Login or Signup to post a comment