@@ -17,11 +17,12 @@ 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+ // var 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
24+ // item.alert = "Swift Push (\(versionNumber)) starting on " + UIDevice.currentDevice().name
25+ item. alert = " Swift Push starting on " + UIDevice. currentDevice ( ) . name
2526
2627 notifications. insert ( item, atIndex: 0 )
2728
@@ -102,37 +103,22 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
102103 // decode mesage and create new object
103104 var t1 : AnyObject ! = userInfo. objectForKey ( " aps " )
104105 var alert = t1. objectForKey ( " alert " ) as String
105- var payload = userInfo. objectForKey ( " payload " ) as String
106+ // var payload = userInfo.objectForKey("payload") as String
106107 // var timeStamp = userInfo.objectForKey("timestamp") as String
107- var messageID = userInfo. objectForKey ( " messageID " ) as Int
108+ // var messageID = userInfo.objectForKey("messageID") as Int
108109
109110 var item = NotificationData ( )
110111 item. alert = alert
111- item. payload = payload
112- // item.timeStamp = NSDate(timeIntervalSince1970: timeStamp)
113- item. messageID = messageID
114-
115-
116- // Is this a new message? Check for exisitance of messageID in array
117- var newItem = true ;
118- for n in notifications {
119- if ( n. messageID == item. messageID) {
120- newItem = false
121- }
122- }
112+ // item.payload = alert
113+ // item.timeStamp = NSDate()
114+ // item.messageID = messageID
123115
124- if ( newItem == true ) {
125- println ( " adding notification " )
126- notifications. insert ( item, atIndex: 0 )
127- if ( notifications. count > maxNotifications) {
128- notifications. removeLast ( )
129- }
130- // notify tableview to refresh
131- let center = NSNotificationCenter . defaultCenter ( )
132- center. postNotificationName ( " dataChanged " , object: self )
133- } else {
134- println ( " duplicate notification - ignoring " )
116+ notifications. insert ( item, atIndex: 0 )
117+ if ( notifications. count > maxNotifications) {
118+ notifications. removeLast ( )
135119 }
120+ let center = NSNotificationCenter . defaultCenter ( )
121+ center. postNotificationName ( " dataChanged " , object: self )
136122
137123 // finished
138124 completionHandler ( UIBackgroundFetchResult . NewData)
0 commit comments