@@ -17,12 +17,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1717 func application( application: UIApplication , didFinishLaunchingWithOptions launchOptions: [ NSObject : AnyObject ] ? ) -> Bool {
1818 // Override point for customization after application launch.
1919
20- // var versionNumber: AnyObject = NSBundle.mainBundle().infoDictionary["CFBundleVersion"]
21- // println ("version \(versionNumber)")
20+ let versionNumber : AnyObject ? = NSBundle . mainBundle ( ) . infoDictionary ? [ " CFBundleVersion " ]
21+ println ( " version \( versionNumber! ) " )
2222
2323 var item = NotificationData ( )
24- // item.alert = "Swift Push (\(versionNumber)) starting on " + UIDevice.currentDevice().name
25- item. alert = " Swift Push starting on " + UIDevice. currentDevice ( ) . name
24+ item. alert = " Swift Push ( \( versionNumber!) ) starting on " + UIDevice. currentDevice ( ) . name
2625 notifications. insert ( item, atIndex: 0 )
2726
2827 switch ( application. applicationState) {
@@ -51,7 +50,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
5150 NSNotificationCenter . defaultCenter ( ) . addObserverForName ( UIApplicationUserDidTakeScreenshotNotification, object: nil , queue: mainQueue) { notification in
5251 println ( " screenshot taken " )
5352 }
54-
5553 return true
5654 }
5755
@@ -63,15 +61,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
6361 NSUserDefaults . standardUserDefaults ( ) . setObject ( deviceToken. description as String , forKey: " deviceToken " )
6462 NSUserDefaults . standardUserDefaults ( ) . synchronize ( )
6563
66- var receipt = NSBundle . mainBundle ( ) . appStoreReceiptURL? . lastPathComponent
64+ let receipt = NSBundle . mainBundle ( ) . appStoreReceiptURL? . lastPathComponent
65+ let versionNumber : AnyObject ? = NSBundle . mainBundle ( ) . infoDictionary ? [ " CFBundleVersion " ]
6766
6867 // register device token with push service
6968 var request = NSMutableURLRequest ( URL: NSURL ( string: " http://www.trease.eu/ibeacon/swiftpush/ " ) !)
7069 var session = NSURLSession . sharedSession ( )
7170 request. HTTPMethod = " POST "
72- var bodyData = " token= " + deviceToken. description
73- + " &device= " + UIDevice. currentDevice ( ) . name
74- + " &mode= " + receipt!
71+ var bodyData = " token= \( deviceToken. description) "
72+ bodyData += " &device= \( UIDevice . currentDevice ( ) . name) "
73+ bodyData += " &mode= \( receipt!) "
74+ bodyData += " &version= \( versionNumber!) "
7575 request. HTTPBody = bodyData. dataUsingEncoding ( NSUTF8StringEncoding)
7676 var connection = NSURLConnection ( request: request, delegate: self , startImmediately: false )
7777 connection? . start ( )
0 commit comments