From 5f67dcba85bbd7aaefe61e05096c9392ce3cacc1 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Mon, 1 Jul 2019 17:14:51 -0700 Subject: [PATCH] [AltStore] Test background app refresh via silent pushes --- AltStore.xcodeproj/project.pbxproj | 11 +++++++++++ AltStore/AltStore.entitlements | 8 ++++++++ AltStore/AppDelegate.swift | 19 +++++++++++++++++++ AltStore/Info.plist | 1 + 4 files changed, 39 insertions(+) create mode 100644 AltStore/AltStore.entitlements diff --git a/AltStore.xcodeproj/project.pbxproj b/AltStore.xcodeproj/project.pbxproj index cf2b24e6..f36df688 100644 --- a/AltStore.xcodeproj/project.pbxproj +++ b/AltStore.xcodeproj/project.pbxproj @@ -241,6 +241,7 @@ BF1E314822A060F400370A3C /* NSError+ALTServerError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSError+ALTServerError.h"; sourceTree = ""; }; BF1E314922A060F400370A3C /* NSError+ALTServerError.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSError+ALTServerError.m"; sourceTree = ""; }; BF1E315022A0616100370A3C /* libAltKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAltKit.a; sourceTree = BUILT_PRODUCTS_DIR; }; + BF219A7E22CAC431007676A6 /* AltStore.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AltStore.entitlements; sourceTree = ""; }; BF3F786322CAA41E008FBD20 /* ALTDeviceManager+Installation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ALTDeviceManager+Installation.swift"; sourceTree = ""; }; BF43002D22A714AF0051E2BC /* Keychain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Keychain.swift; sourceTree = ""; }; BF43002F22A71C960051E2BC /* UserDefaults+AltStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserDefaults+AltStore.swift"; sourceTree = ""; }; @@ -696,6 +697,7 @@ BFD2476C2284B9A500981D42 /* AltStore */ = { isa = PBXGroup; children = ( + BF219A7E22CAC431007676A6 /* AltStore.entitlements */, BFD2476D2284B9A500981D42 /* AppDelegate.swift */, BFD247732284B9A500981D42 /* Main.storyboard */, BFE6325822A83BA800F30809 /* Authentication */, @@ -1008,6 +1010,9 @@ com.apple.BackgroundModes = { enabled = 1; }; + com.apple.Push = { + enabled = 1; + }; }; }; }; @@ -1600,6 +1605,8 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = AltStore/AltStore.entitlements; + CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6XVY5G3U44; INFOPLIST_FILE = AltStore/Info.plist; @@ -1610,6 +1617,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.rileytestut.AltStore; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 1; @@ -1622,6 +1630,8 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = AltStore/AltStore.entitlements; + CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6XVY5G3U44; INFOPLIST_FILE = AltStore/Info.plist; @@ -1632,6 +1642,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.rileytestut.AltStore; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 1; }; diff --git a/AltStore/AltStore.entitlements b/AltStore/AltStore.entitlements new file mode 100644 index 00000000..903def2a --- /dev/null +++ b/AltStore/AltStore.entitlements @@ -0,0 +1,8 @@ + + + + + aps-environment + development + + diff --git a/AltStore/AppDelegate.swift b/AltStore/AppDelegate.swift index 663aa5e2..81928f17 100644 --- a/AltStore/AppDelegate.swift +++ b/AltStore/AppDelegate.swift @@ -102,6 +102,25 @@ extension AppDelegate UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { (success, error) in } + + #if DEBUG + UIApplication.shared.registerForRemoteNotifications() + #endif + } + + func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) + { + let tokenParts = deviceToken.map { data -> String in + return String(format: "%02.2hhx", data) + } + + let token = tokenParts.joined() + print("Push Token:", token) + } + + func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) + { + self.application(application, performFetchWithCompletionHandler: completionHandler) } func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) diff --git a/AltStore/Info.plist b/AltStore/Info.plist index 6db2ac23..dcbcf534 100644 --- a/AltStore/Info.plist +++ b/AltStore/Info.plist @@ -45,6 +45,7 @@ audio fetch + remote-notification UILaunchStoryboardName LaunchScreen