Skip to content

Commit cef4a6c

Browse files
authored
Merge pull request #9 from akonakov/swift-new
Adds scriptKey support
2 parents 52111b9 + 9293992 commit cef4a6c

File tree

4 files changed

+173
-165
lines changed

4 files changed

+173
-165
lines changed

todolist.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@
353353
};
354354
6277357F1DBFD92300CFC713 = {
355355
CreatedOnToolsVersion = 8.0;
356-
DevelopmentTeam = Q9F94SAMUV;
356+
DevelopmentTeam = 2Y98Z4WG4M;
357357
LastSwiftMigration = 0900;
358358
ProvisioningStyle = Automatic;
359359
SystemCapabilities = {
@@ -670,7 +670,7 @@
670670
CLANG_ENABLE_MODULES = YES;
671671
CODE_SIGN_IDENTITY = "";
672672
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
673-
DEVELOPMENT_TEAM = Q9F94SAMUV;
673+
DEVELOPMENT_TEAM = 2Y98Z4WG4M;
674674
INFOPLIST_FILE = todolist/Info.plist;
675675
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
676676
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
@@ -691,7 +691,7 @@
691691
CLANG_ENABLE_MODULES = YES;
692692
CODE_SIGN_IDENTITY = "";
693693
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
694-
DEVELOPMENT_TEAM = Q9F94SAMUV;
694+
DEVELOPMENT_TEAM = 2Y98Z4WG4M;
695695
INFOPLIST_FILE = todolist/Info.plist;
696696
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
697697
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";

todolist/AppDelegate.swift

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import UserNotifications
1111

1212
@UIApplicationMain
1313
class AppDelegate: UIResponder, UIApplicationDelegate {
14-
14+
1515
var window: UIWindow?
1616
let user = User.sharedInstance
1717
var alerts = [String]()
@@ -24,7 +24,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2424
center.delegate = self
2525
center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
2626
if error == nil{
27-
UIApplication.shared.registerForRemoteNotifications()
27+
DispatchQueue.main.async {
28+
UIApplication.shared.registerForRemoteNotifications()
29+
}
2830
}
2931
}
3032
} else {
@@ -40,34 +42,35 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
4042
let accessKey = "b28b2afa05e14ad481aa358b23210a73"
4143
let fileKey = "3824781938324a8a81025d7e6594d901"
4244
let messageKey = "9de581f126354bf2bf304f3dd7af2142"
43-
SC.initWith(applicationId: applicationId, clientId: clientId, accessKey: accessKey, fileKey: fileKey, messageKey: messageKey)
45+
let scriptKey = "9de581f126354bf2bf304f3dd7af2142"
46+
SC.initWith(applicationId: applicationId, clientId: clientId, accessKey: accessKey, fileKey: fileKey, messageKey: messageKey, scriptKey: scriptKey)
4447

4548
// Check if launched from notification
4649
if let notification = launchOptions?[UIApplicationLaunchOptionsKey.remoteNotification] {
4750
performActionOnPushNotification(userInfo: notification as! [NSObject : AnyObject])
4851
}
4952
return true
5053
}
51-
54+
5255
func applicationWillResignActive(_ application: UIApplication) {
5356
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
5457
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
5558
}
56-
59+
5760
func applicationDidEnterBackground(_ application: UIApplication) {
5861
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
5962
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
6063
}
61-
64+
6265
func applicationWillEnterForeground(_ application: UIApplication) {
6366
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
6467
}
65-
68+
6669
func applicationDidBecomeActive(_ application: UIApplication) {
6770
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
6871
application.applicationIconBadgeNumber = 0;
6972
}
70-
73+
7174
func applicationWillTerminate(_ application: UIApplication) {
7275
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
7376
}
@@ -93,13 +96,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
9396
}
9497

9598
private func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject],
96-
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
99+
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
97100
// If you are receiving a notification message while your app is in the background,
98101
// this callback will not be fired till the user taps on the notification launching the application.
99102
print("Received notification: \(userInfo)");
100103
performActionOnPushNotification(userInfo: userInfo)
101104
}
102-
105+
103106
func performActionOnPushNotification(userInfo: [NSObject : AnyObject]) {
104107
print("receive an push, notification, trying to parse...")
105108
if let aps = userInfo[("aps" as NSString)] as? [String: Any] {

0 commit comments

Comments
 (0)