Skip to content

Commit 225c013

Browse files
author
Steve Trease
committed
Fixed.
1 parent 5b41c0e commit 225c013

File tree

6 files changed

+23
-21
lines changed

6 files changed

+23
-21
lines changed

Swift Push 3.xcodeproj/project.xcworkspace/xcshareddata/Swift Push 3.xccheckout

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<key>IDESourceControlWCCIdentifierKey</key>
3535
<string>6818D98FE4D96D546CB056A69C096B3C1BF2C193</string>
3636
<key>IDESourceControlWCCName</key>
37-
<string>swiftpush</string>
37+
<string>Swift%20Push%203</string>
3838
</dict>
3939
</array>
4040
</dict>

Swift Push 3/AppDelegate.swift

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
5656
}
5757

5858

59-
func application(application: UIApplication!, didRegisterForRemoteNotificationsWithDeviceToken deviceToken:NSData!) {
59+
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken:NSData) {
6060
let existingToken: AnyObject? = NSUserDefaults.standardUserDefaults().objectForKey("deviceToken")
6161

6262
println("device token is " + deviceToken.description)
@@ -66,7 +66,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
6666
var receipt = NSBundle.mainBundle().appStoreReceiptURL?.lastPathComponent
6767

6868
// register device token with push service
69-
var request = NSMutableURLRequest(URL: NSURL(string: "https://www.trease.eu/ibeacon/swiftpush/")!)
69+
var request = NSMutableURLRequest(URL: NSURL(string: "http://www.trease.eu/ibeacon/swiftpush/")!)
7070
var session = NSURLSession.sharedSession()
7171
request.HTTPMethod = "POST"
7272
var bodyData = "token=" + deviceToken.description
@@ -78,13 +78,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
7878
}
7979

8080

81-
func application(application: UIApplication!, didFailToRegisterForRemoteNotificationsWithError error:NSError!) {
81+
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error:NSError) {
8282
println("Failed to register device token")
8383
println( error.localizedDescription )
8484
}
8585

86-
87-
func application(application: UIApplication!, didReceiveRemoteNotification userInfo:NSDictionary!, fetchCompletionHandler completionHandler: ((UIBackgroundFetchResult) -> Void)!) {
86+
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
8887
switch (application.applicationState) {
8988
case UIApplicationState.Active:
9089
println ("notification received by AppDeligate whilst active")
@@ -97,15 +96,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
9796
}
9897
println (userInfo)
9998

100-
// decode mesage and create new object
101-
var t1: AnyObject! = userInfo.objectForKey("aps")
102-
var alert = t1.objectForKey("alert") as String
99+
var item = NotificationData()
100+
101+
if let aps = userInfo["aps"] as? NSDictionary {
102+
if let alert = aps["alert"] as? String {
103+
item.alert = alert
104+
}
105+
}
106+
103107
// var payload = userInfo.objectForKey("payload") as String
104108
// var timeStamp = userInfo.objectForKey("timestamp") as String
105109
// var messageID = userInfo.objectForKey("messageID") as Int
106110

107-
var item = NotificationData()
108-
item.alert = alert
109111
// item.payload = alert
110112
// item.timeStamp = NSDate()
111113
// item.messageID = messageID
@@ -119,7 +121,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
119121

120122
// finished
121123
completionHandler(UIBackgroundFetchResult.NewData)
122-
123124
}
124125

125126
func applicationWillResignActive(application: UIApplication) {
@@ -151,7 +152,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
151152
lazy var applicationDocumentsDirectory: NSURL = {
152153
// The directory the application uses to store the Core Data store file. This code uses a directory named "Trease.Swift_Push_3" in the application's documents Application Support directory.
153154
let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
154-
return urls[urls.count-1] as NSURL
155+
return urls[urls.count-1] as! NSURL
155156
}()
156157

157158
lazy var managedObjectModel: NSManagedObjectModel = {

Swift Push 3/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>279</string>
22+
<string>289</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>UIBackgroundModes</key>

Swift Push 3/NotificationsTableViewController.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ class NotificationsTableViewController: UITableViewController, UISearchBarDelega
2020
})
2121
}
2222

23-
func searchDisplayController(controller: UISearchDisplayController!, shouldReloadTableForSearchString searchString: String!) -> Bool {
24-
filterContentForSearchText(searchString)
23+
func searchDisplayController(controller: UISearchController!, shouldReloadTableForSearchString searchString: String!) -> Bool {
24+
self.filterContentForSearchText(searchString)
2525
println("searchDisplayController:")
2626
return true
2727
}
2828

29-
func searchDisplayController(controller: UISearchDisplayController!, shouldReloadTableForSearchScope searchOption: Int) -> Bool {
30-
filterContentForSearchText(self.searchDisplayController!.searchBar.text)
29+
func searchDisplayController(controller: UISearchController!, shouldReloadTableForSearchScope searchOption: Int) -> Bool {
30+
// self.filterContentForSearchText(self.searchDisplayController!.searchBar.text)
31+
self.filterContentForSearchText(controller.searchBar.text)
3132
println("searchDisplayController")
3233
return true
3334
}
@@ -76,13 +77,13 @@ class NotificationsTableViewController: UITableViewController, UISearchBarDelega
7677
println("cellForRowAtIndexPath ", indexPath.row)
7778

7879
var notification : NotificationData
79-
if tableView == self.searchDisplayController!.searchResultsTableView {
80+
if tableView == searchDisplayController!.searchResultsTableView {
8081
notification = filteredNotifications[indexPath.row]
8182
} else {
8283
notification = notifications[indexPath.row]
8384
}
8485

85-
let cell: UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("ReuseCell", forIndexPath: indexPath) as UITableViewCell
86+
let cell: UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("ReuseCell", forIndexPath: indexPath) as! UITableViewCell
8687

8788
// let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "ReuseCell")
8889

Swift Push 3/Settings.bundle/Root.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<array>
77
<dict>
88
<key>DefaultValue</key>
9-
<string>279</string>
9+
<string>289</string>
1010
<key>Key</key>
1111
<string>CurrentBuildNumber</string>
1212
<key>Title</key>

0 commit comments

Comments
 (0)