Swift2. How do I sent push to my users?

I have set up everything correctly (I think).
If I push with a php script with my terminal, I receive the push.

I’ve set up backendelss with:

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        backendless.initApp(APP_ID, secret: SECRET_KEY, version: VERSION_NUM)
        
        let sharedApp = UIApplication.sharedApplication()
        sharedApp.registerForRemoteNotifications()
        let notifySettings = UIUserNotificationSettings(forTypes: [.Sound, .Alert, .Badge], categories: nil)
        sharedApp.registerUserNotificationSettings(notifySettings)
        
        backendless.messaging.registerForRemoteNotifications()
        return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    }
    
    func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
        print("token: \(deviceToken)")
        backendless.messaging.registerDeviceToken("deviceToken")
    }

In the backendless Push Section I’m finding my device with a Device ID (CD37FEC1-5F99-4759-…)
I’m selcting that device, put in a Message Text, put in “ios-alert”:“test” as Header. Press Publish.
It says “Message Scheduled”, but that’s it. No Push…
What am I missing?

And please. I need help in Swift. I’m not familiar with Obj C.

Hi David,

The right header is “alert-text”.

A few questions for you:

Have you uploaded certificate to Backendless?
Does the certificate have a password?
Does the app bundle ID match the app ID from Apple’s developer console?
Have you deployed provisioning profile to keychain?
What type of certificate did you generate?(sandbox or universal)
What does the code signing authority show in xcode?

Regards,
Mark

Hi. Same thing with “alert-text”:“Test”

Have you uploaded certificate to Backendless?
Yes

Does the certificate have a password?
Yes and I provided it

Does the app bundle ID match the app ID from Apple’s developer console?
I’m not totally sure what you mean, but I think yes. Because, like I said, I’m able to send push with my own php script.

Have you deployed provisioning profile to keychain?
Again not totally sure what you mean, but since I’m able to send push without backendless, I’m sure I have set up push between Apple and my App correctly.

What type of certificate did you generate?(sandbox or universal)
Universal.

What does the code signing authority show in xcode?
Xcode -> Preferences -> Accounts -> Apple IDs -> I just see me as iOS Agent. Is that okay?
Or do you mean something else?

Does the app bundle ID match the app ID from Apple’s developer console?
I’m not totally sure what you mean, but I think yes. Because, like I said, I’m able to send push with my own php script.
See the step 9 from here: https://backendless.com/documentation/messaging/ios/messaging_xcode_setup_for_apn.htm
Have you deployed provisioning profile to keychain?
Again not totally sure what you mean, but since I’m able to send push without backendless, I’m sure I have set up push between Apple and my App correctly.

Please see the “Verify Signing Identities Using Keychain Access” section at:
https://developer.apple.com/library/mac/documentation/IDEs/Conceptual/AppStoreDistributionTutorial/LaunchingYourApponDevices/LaunchingYourApponDevices.html
What does the code signing authority show in xcode?
Xcode -> Preferences -> Accounts -> Apple IDs -> I just see me as iOS Agent. Is that okay?
See the step 10 here:
https://backendless.com/documentation/messaging/ios/messaging_xcode_setup_for_apn.htm

Does the app bundle ID match the app ID from Apple’s developer console?
is perfectly entered

Have you deployed provisioning profile to keychain?
my iPhone Feveloper Certificate is valid

What does the code signing authority show in xcode?
yes everything is set up fine

So. Yes. Everything is set up… what to do now? :S

Is this correct?

http://support.backendless.com/public/attachments/e0cae7581a6d48e99d5fd9ceb0dd9c74.png</img>

Like I said, using a php script running from my terminal I’m able to display every push notification I want. I don’t get the problem…

Does the php script send notifications through Backendless?

see below

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        backendless.initApp(APP_ID, secret: SECRET_KEY, version: VERSION_NUM)
        backendless.messaging.registerForRemoteNotifications()
        
        let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
        application.registerUserNotificationSettings(settings)
        application.registerForRemoteNotifications()
        
        return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    }

What did you change to get it working?

No it does not. It is just a simple script sending a Push just to my own device. With my Token hardcoded

It is finally working… But the push is without a sound…

How do I have to configure the header just to play the standart alert sound?
Or do you want me to open a new topic for that?

I can’t tell… I just did all the steps again and now it is working… Not I’m just not sure how to find the name of the standart library sounds…

I’ll find out from our iOS devs and let you know by tomorrow morning.

Regards,
Mark

This is how I solved it.

After I enabled push notification in app settings in xcode :slight_smile:

Sending from backendless console…

Header: “ios-alert”:“some text”,“ios-badge”:“1”,“ios-sound”:“default”

Ref. apple doc. –
For remote notifications in iOS, you can specify a custom sound that
iOS plays when it presents a local or remote notification for an app.
The sound files can be in the main bundle of the client app or in the Library/Sounds folder of the app’s data container.
Custom alert sounds are played by the iOS system-sound facility, so they must be in one of the following audio data formats:

    Linear PCM MA4 (IMA/ADPCM) µLaw aLaw
You can package the audio data in an aiff, wav, or caf file. Then, in Xcode, add the sound file to your project as a nonlocalized resource of the app bundle or to the Library/Sounds folder of your data container.

Thanks, Emil. This is exactly what I got from our developers as well.

Regards,
Mark

did anything changed? I can’t send pushes anymore…

http://support.backendless.com/public/attachments/baa32b83115f6d723f41ab3571fac392.png</img>