I'm trying to set up iOS Push Notifications and I've been going round in circles for the past 4 hours and got nowhere.
The app is written in Swift 2.3.
I set up the AppBoy application...
Appboy.startWithApiKey("blahblahblahblah", inApplication:application, withLaunchOptions:launchOptions)
And I can see that there are users of the iOS app in the segment I created.
In code I then register for notifications and use this code to send the device token up to AppBoy...
extension NSData {
func hexString() -> String {
// "Array" of all bytes:
let bytes = UnsafeBufferPointer<UInt8>(start: UnsafePointer(self.bytes), count:self.length)
// Array of hex strings, one for each byte:
let hexBytes = bytes.map { String(format: "%02hhx", $0) }
// Concatenate all hex strings:
return hexBytes.joinWithSeparator("")
}
}
And this...
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
let token = deviceToken.hexString()
Appboy.sharedInstance()?.registerPushToken(token)
}
However, when I update the filter on the Segment in AppBoy to filter by "Push Enabled" I get 0 devices. (I'm not even sure if Push Enabled is the correct filter?)
As a secondary question. The certificate that I upload to AppBoy is telling me it is a "Universal certificate" and the newest method of delivering notifications. Is this the right certificate to upload to AppBoy?
I have created a campaign with the segment I created and it shows as having one message delivered.
But whatever I do nothing is coming through to my device.
The version of the app installed on my device is the one downloaded and installed through Crashlytics.
Thanks
Update
OK, so now I'm getting devices showing up as "Push Enabled" but when I try to send a push notification the error log in the developer console shows "Error sending to a bad push token..."
The certificate I have shows like this...
Can anyone explain what I'm doing wrong? I have followed every troubleshooting guide and triple checked the setup and redone every step several times.
If you are getting the prompt to accept push notifications from your app but your user profile within Braze's dashboard is not being updated as expected, make sure that you are correctly formatting the device token before passing it back to Braze. Code below and more details available here.
If you are worried about which certificate to add to the Braze dashboard, I recommend using a .p8 downloaded from your apple developer account. Detailed instructions here.
An easy mistake to make is forgetting to update the environment setting in the Braze Dashboard and within your apps entitlement settings. While you are developing and testing the app on a simulator or side loaded onto your test device, be sure that the environment setting just above the certificate details in the Braze dashboard is set to Development. Once you move it to TestFlight and the App Store, you will need to update this to Production.
Hope this helps.