I followed the instructions here to set up push notifications for iOS, with a bit of changes since the instructions were only for Swift. I also configured push notifications to “on” in the capabilities section. After that, I created a simple test app that would send out a push notification when a button was pressed. However, when I ran it on my device, no notification was received. I’ve tried changing the code signing settings several times, but it either does nothing, or Xcode throws an error and resets them. In another test app that was virtually identical, I got the push notifications to work, but I must’ve changed something in the settings, because when I tried it again, nothing happened. Similarly, notifications sent from the console aren’t received either.
One thing is that the team id used for my app ids matches my iOS distribution certificate, not my iOS development, so I initially created a production profile to use with this app instead of a development, but neither of them worked in the end.
This is my AppDelegate code:
class AppDelegate: UIResponder, UIApplicationDelegate {
let APP_ID = "[app id]"
let SECRET_KEY = "[key]"
let VERSION_NUM = "v1"
var backendless = Backendless.sharedInstance()
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
backendless.initApp(APP_ID, secret:SECRET_KEY, version:VERSION_NUM)
backendless.messaging.registerForRemoteNotifications()
return true
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
backendless.messaging.registerDeviceToken(deviceToken)
backendless.messaging.registerDevice(["default"])
}
}
This is my ViewController:
class ViewController: UIViewController {
@IBAction func pressed(sender: AnyObject) {
Backendless.sharedInstance().messaging.publish("default", message: "Hello world")
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
And this is what my code signing settings looks like:
http://support.backendless.com/public/attachments/d7cabd5d1a5b7e0dd4b96566d24e2960.png</img>
Several things that I tried were:
- Selecting the production profile for the provisioning profile and changing the code-signing values to iPhone Distribution. Xcode threw an error and reset the values.
Selecting the development profile and changing code-signing values to iPhone Developer. Also an error, and values were reset.
Changing values to iOS Developer instead. Also an error.
Changing values to iOS Distribution instead. Error.
Changed to production profile. Error.
Changed values to iOS Developer again without changing profile. Error.
Changed values to iPhone Developer. Again, error.