1

I want to send Push Notifications via a PHP script to all app users. About Google Unfortunately there are no tutorials for Push Notifications with Swift. Parse.com I do not want to use. Can anyone help me please?

4
  • Swift or php? Show us what you have tried so far. Commented Feb 6, 2015 at 23:38
  • I want to send Push Notifications from PHP Script to my IOS App. Sorry I can´t try anything, because i found only Objective-C Tutorials and i need Swift. Commented Feb 6, 2015 at 23:44
  • There are plenty of examples on sending push notifications using php. Commented Feb 7, 2015 at 7:30
  • Yes php and Xcode objective-c but not php and Xcode Swift Commented Feb 7, 2015 at 23:22

1 Answer 1

3

OK now it works ! (:

Create Certificate for APN: raywenderlich.com

Swift Code:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {


    // Override point for customization after application launch.



    var type = UIUserNotificationType.Badge | UIUserNotificationType.Alert | UIUserNotificationType.Sound

    var setting = UIUserNotificationSettings(forTypes: type, categories: nil)

    UIApplication.sharedApplication().registerUserNotificationSettings(setting)

    UIApplication.sharedApplication().registerForRemoteNotifications()



    return true

}



func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {

    println(deviceToken)

}

func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {

    println(error)

}

find the deviceToken in the Xcode Console

PHP Script

use the PHP Script from here raywenderlich.com (scroll down)

run the PHP Script and viola (:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.