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?
-
Swift or php? Show us what you have tried so far.oefe– oefe2015-02-06 23:38:45 +00:00Commented 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.DKCode– DKCode2015-02-06 23:44:34 +00:00Commented Feb 6, 2015 at 23:44
-
There are plenty of examples on sending push notifications using php.oefe– oefe2015-02-07 07:30:39 +00:00Commented Feb 7, 2015 at 7:30
-
Yes php and Xcode objective-c but not php and Xcode SwiftDKCode– DKCode2015-02-07 23:22:08 +00:00Commented Feb 7, 2015 at 23:22
Add a comment
|
1 Answer
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 (: