mirror of
https://github.com/Finb/Bark.git
synced 2025-12-08 21:36:01 +00:00
URL跳转,复制推送内容
This commit is contained in:
parent
9481d5a009
commit
57e9b55197
@ -12,6 +12,11 @@
|
||||
0603706B20E20A7C00F4CA05 /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0603706A20E20A7C00F4CA05 /* String+Extension.swift */; };
|
||||
0603706D20E23EC000F4CA05 /* BarkSFSafariViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0603706C20E23EC000F4CA05 /* BarkSFSafariViewController.swift */; };
|
||||
0604F7DF20620D4900B32F09 /* ServerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0604F7DE20620D4900B32F09 /* ServerManager.swift */; };
|
||||
0632CE1F20EC9098003FDF46 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0683487020510FB20024B6DA /* UserNotifications.framework */; };
|
||||
0632CE2020EC9098003FDF46 /* UserNotificationsUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0683487220510FB20024B6DA /* UserNotificationsUI.framework */; };
|
||||
0632CE2320EC9098003FDF46 /* NotificationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0632CE2220EC9098003FDF46 /* NotificationViewController.swift */; };
|
||||
0632CE2620EC9098003FDF46 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0632CE2420EC9098003FDF46 /* MainInterface.storyboard */; };
|
||||
0632CE2A20EC9098003FDF46 /* NotificationContentExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 0632CE1E20EC9098003FDF46 /* NotificationContentExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
0637FA7820E0926D00E80174 /* BarkTargetType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0637FA7720E0926D00E80174 /* BarkTargetType.swift */; };
|
||||
0637FA7A20E092B300E80174 /* Observable+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0637FA7920E092B300E80174 /* Observable+Extension.swift */; };
|
||||
0637FA7C20E0930E00E80174 /* BarkApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0637FA7B20E0930E00E80174 /* BarkApi.swift */; };
|
||||
@ -26,15 +31,44 @@
|
||||
0661A545204FDA4100965E4E /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0661A544204FDA4100965E4E /* HomeViewController.swift */; };
|
||||
0661A54A204FDA4100965E4E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0661A549204FDA4100965E4E /* Assets.xcassets */; };
|
||||
0661A54D204FDA4100965E4E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0661A54B204FDA4100965E4E /* LaunchScreen.storyboard */; };
|
||||
06802E5320ECC40C00767047 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0661A549204FDA4100965E4E /* Assets.xcassets */; };
|
||||
4A97FDFB8C102B8A492ED65A /* Pods_Bark.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D155DFC7B804DC5518C01D75 /* Pods_Bark.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
0632CE2820EC9098003FDF46 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 0661A537204FDA4100965E4E /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 0632CE1D20EC9098003FDF46;
|
||||
remoteInfo = NotificationContentExtension;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
0632CE2E20EC9098003FDF46 /* Embed App Extensions */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 13;
|
||||
files = (
|
||||
0632CE2A20EC9098003FDF46 /* NotificationContentExtension.appex in Embed App Extensions */,
|
||||
);
|
||||
name = "Embed App Extensions";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
0603706620E1E31600F4CA05 /* Defines.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Defines.swift; sourceTree = "<group>"; };
|
||||
0603706820E1F89500F4CA05 /* PreviewCardCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewCardCell.swift; sourceTree = "<group>"; };
|
||||
0603706A20E20A7C00F4CA05 /* String+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extension.swift"; sourceTree = "<group>"; };
|
||||
0603706C20E23EC000F4CA05 /* BarkSFSafariViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarkSFSafariViewController.swift; sourceTree = "<group>"; };
|
||||
0604F7DE20620D4900B32F09 /* ServerManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerManager.swift; sourceTree = "<group>"; };
|
||||
0632CE1E20EC9098003FDF46 /* NotificationContentExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = NotificationContentExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
0632CE2220EC9098003FDF46 /* NotificationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationViewController.swift; sourceTree = "<group>"; };
|
||||
0632CE2520EC9098003FDF46 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
|
||||
0632CE2720EC9098003FDF46 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
0637FA7720E0926D00E80174 /* BarkTargetType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarkTargetType.swift; sourceTree = "<group>"; };
|
||||
0637FA7920E092B300E80174 /* Observable+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Observable+Extension.swift"; sourceTree = "<group>"; };
|
||||
0637FA7B20E0930E00E80174 /* BarkApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarkApi.swift; sourceTree = "<group>"; };
|
||||
@ -55,12 +89,22 @@
|
||||
0683486A2050F1310024B6DA /* Bark.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Bark.entitlements; sourceTree = "<group>"; };
|
||||
0683487020510FB20024B6DA /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; };
|
||||
0683487220510FB20024B6DA /* UserNotificationsUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotificationsUI.framework; path = System/Library/Frameworks/UserNotificationsUI.framework; sourceTree = SDKROOT; };
|
||||
14F0F73EC45A35FC2482F967 /* Pods_NotificationContentExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NotificationContentExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
1CC985CE300A858FF65E166A /* Pods-Bark.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Bark.release.xcconfig"; path = "Pods/Target Support Files/Pods-Bark/Pods-Bark.release.xcconfig"; sourceTree = "<group>"; };
|
||||
87D1222A4C6E7283974A44C6 /* Pods-Bark.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Bark.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Bark/Pods-Bark.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
D155DFC7B804DC5518C01D75 /* Pods_Bark.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Bark.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
0632CE1B20EC9098003FDF46 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
0632CE2020EC9098003FDF46 /* UserNotificationsUI.framework in Frameworks */,
|
||||
0632CE1F20EC9098003FDF46 /* UserNotifications.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
0661A53C204FDA4100965E4E /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -108,6 +152,16 @@
|
||||
path = Model;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0632CE2120EC9098003FDF46 /* NotificationContentExtension */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0632CE2220EC9098003FDF46 /* NotificationViewController.swift */,
|
||||
0632CE2420EC9098003FDF46 /* MainInterface.storyboard */,
|
||||
0632CE2720EC9098003FDF46 /* Info.plist */,
|
||||
);
|
||||
path = NotificationContentExtension;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0661A536204FDA4100965E4E = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -115,6 +169,7 @@
|
||||
0604F7DC20620D3400B32F09 /* View */,
|
||||
0604F7DB20620D2700B32F09 /* Controller */,
|
||||
0661A541204FDA4100965E4E /* Bark */,
|
||||
0632CE2120EC9098003FDF46 /* NotificationContentExtension */,
|
||||
0661A540204FDA4100965E4E /* Products */,
|
||||
9563D0DB71FE280909AB1C63 /* Pods */,
|
||||
99BD309BDB7F62B5DC0CECE1 /* Frameworks */,
|
||||
@ -125,6 +180,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0661A53F204FDA4100965E4E /* Bark.app */,
|
||||
0632CE1E20EC9098003FDF46 /* NotificationContentExtension.appex */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@ -157,6 +213,7 @@
|
||||
D155DFC7B804DC5518C01D75 /* Pods_Bark.framework */,
|
||||
0683487020510FB20024B6DA /* UserNotifications.framework */,
|
||||
0683487220510FB20024B6DA /* UserNotificationsUI.framework */,
|
||||
14F0F73EC45A35FC2482F967 /* Pods_NotificationContentExtension.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
@ -164,6 +221,23 @@
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
0632CE1D20EC9098003FDF46 /* NotificationContentExtension */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 0632CE2D20EC9098003FDF46 /* Build configuration list for PBXNativeTarget "NotificationContentExtension" */;
|
||||
buildPhases = (
|
||||
0632CE1A20EC9098003FDF46 /* Sources */,
|
||||
0632CE1B20EC9098003FDF46 /* Frameworks */,
|
||||
0632CE1C20EC9098003FDF46 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = NotificationContentExtension;
|
||||
productName = NotificationContentExtension;
|
||||
productReference = 0632CE1E20EC9098003FDF46 /* NotificationContentExtension.appex */;
|
||||
productType = "com.apple.product-type.app-extension";
|
||||
};
|
||||
0661A53E204FDA4100965E4E /* Bark */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 0661A551204FDA4100965E4E /* Build configuration list for PBXNativeTarget "Bark" */;
|
||||
@ -174,10 +248,12 @@
|
||||
0661A53D204FDA4100965E4E /* Resources */,
|
||||
CFBB713B64655C7E71F4587A /* [CP] Embed Pods Frameworks */,
|
||||
BDEDA44DC34CE9C81E76AECC /* [CP] Copy Pods Resources */,
|
||||
0632CE2E20EC9098003FDF46 /* Embed App Extensions */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
0632CE2920EC9098003FDF46 /* PBXTargetDependency */,
|
||||
);
|
||||
name = Bark;
|
||||
productName = Bark;
|
||||
@ -190,10 +266,14 @@
|
||||
0661A537204FDA4100965E4E /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0920;
|
||||
LastSwiftUpdateCheck = 0930;
|
||||
LastUpgradeCheck = 0930;
|
||||
ORGANIZATIONNAME = Fin;
|
||||
TargetAttributes = {
|
||||
0632CE1D20EC9098003FDF46 = {
|
||||
CreatedOnToolsVersion = 9.3;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
0661A53E204FDA4100965E4E = {
|
||||
CreatedOnToolsVersion = 9.2;
|
||||
ProvisioningStyle = Automatic;
|
||||
@ -220,11 +300,21 @@
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
0661A53E204FDA4100965E4E /* Bark */,
|
||||
0632CE1D20EC9098003FDF46 /* NotificationContentExtension */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
0632CE1C20EC9098003FDF46 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
06802E5320ECC40C00767047 /* Assets.xcassets in Resources */,
|
||||
0632CE2620EC9098003FDF46 /* MainInterface.storyboard in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
0661A53D204FDA4100965E4E /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -318,6 +408,14 @@
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
0632CE1A20EC9098003FDF46 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
0632CE2320EC9098003FDF46 /* NotificationViewController.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
0661A53B204FDA4100965E4E /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -343,7 +441,23 @@
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
0632CE2920EC9098003FDF46 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 0632CE1D20EC9098003FDF46 /* NotificationContentExtension */;
|
||||
targetProxy = 0632CE2820EC9098003FDF46 /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
0632CE2420EC9098003FDF46 /* MainInterface.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
0632CE2520EC9098003FDF46 /* Base */,
|
||||
);
|
||||
name = MainInterface.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
063C499720E36BF9001BCA35 /* Localizable.strings */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
@ -364,6 +478,40 @@
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
0632CE2B20EC9098003FDF46 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = 5U8LBRXG3A;
|
||||
INFOPLIST_FILE = NotificationContentExtension/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = me.fin.bark.NotificationContentExtension;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TARGETED_DEVICE_FAMILY = 1;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
0632CE2C20EC9098003FDF46 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = 5U8LBRXG3A;
|
||||
INFOPLIST_FILE = NotificationContentExtension/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = me.fin.bark.NotificationContentExtension;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TARGETED_DEVICE_FAMILY = 1;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
0661A54F204FDA4100965E4E /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
@ -481,6 +629,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 87D1222A4C6E7283974A44C6 /* Pods-Bark.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = Bark/Bark.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
@ -499,6 +648,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 1CC985CE300A858FF65E166A /* Pods-Bark.release.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = Bark/Bark.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
@ -516,6 +666,15 @@
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
0632CE2D20EC9098003FDF46 /* Build configuration list for PBXNativeTarget "NotificationContentExtension" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
0632CE2B20EC9098003FDF46 /* Debug */,
|
||||
0632CE2C20EC9098003FDF46 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
0661A53A204FDA4100965E4E /* Build configuration list for PBXProject "Bark" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
|
||||
@ -22,6 +22,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
self.window?.rootViewController = BarkSnackbarController(rootViewController: BarkNavigationController(rootViewController: HomeViewController()))
|
||||
self.window?.makeKeyAndVisible()
|
||||
|
||||
UNUserNotificationCenter.current().setNotificationCategories([
|
||||
UNNotificationCategory(identifier: "myNotificationCategory", actions: [
|
||||
UNNotificationAction(identifier: "copy", title: NSLocalizedString("Copy2"), options: UNNotificationActionOptions.init(rawValue: 0))
|
||||
], intentIdentifiers: [], options: .customDismissAction)
|
||||
])
|
||||
|
||||
UNUserNotificationCenter.current().getNotificationSettings { (settings) in
|
||||
dispatch_sync_safely_main_queue {
|
||||
if settings.authorizationStatus == .authorized {
|
||||
@ -46,6 +52,23 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
//注册设备
|
||||
Client.shared.bindDeviceToken()
|
||||
}
|
||||
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
|
||||
if let urlStr = userInfo["url"] as? String{
|
||||
if let url = URL(string: urlStr) {
|
||||
if ["http","https"].contains(url.scheme?.lowercased() ?? ""){
|
||||
((self.window?.rootViewController as? BarkSnackbarController)?
|
||||
.rootViewController as? BarkNavigationController)?
|
||||
.present(BarkSFSafariViewController(url: url), animated: true, completion: nil)
|
||||
}
|
||||
else{
|
||||
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
||||
}
|
||||
}
|
||||
else{
|
||||
(self.window?.rootViewController as? BarkSnackbarController)?.rootViewController.showSnackbar(text: "URL好像不对劲!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func applicationWillResignActive(_ application: UIApplication) {
|
||||
// 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.
|
||||
|
||||
21
Bark/Assets.xcassets/copyTest.imageset/Contents.json
vendored
Normal file
21
Bark/Assets.xcassets/copyTest.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "copyTest@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
BIN
Bark/Assets.xcassets/copyTest.imageset/copyTest@2x.png
vendored
Normal file
BIN
Bark/Assets.xcassets/copyTest.imageset/copyTest@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 93 KiB |
@ -11,13 +11,14 @@ SecureConnection = "Secure Connection (HTTPS)";
|
||||
InsecureConnection = "Insecure Connection (HTTP)";
|
||||
RegisterDevice = "Register Device";
|
||||
|
||||
CustomedNotifictionContent = "Customed Notifiction Content";
|
||||
CustomedNotifictionTitle = "Customed Notifiction Title";
|
||||
CustomedNotificationContent = "Customed Notification Content";
|
||||
CustomedNotificationTitle = "Customed Notification Title";
|
||||
|
||||
Notice1 = "Click on the buttons in the upper right corner \nto copy or preview test URL";
|
||||
Notice2 = "";
|
||||
Notice2 = "Customed notification content and title";
|
||||
|
||||
Copy = "Copied!";
|
||||
Copy2 = "Copy";
|
||||
|
||||
AllowNotifications = "Notifications have been turned off, Please allow notifications and try again";
|
||||
|
||||
@ -38,3 +39,7 @@ AddedSuccessfully = "Added Successfully!";
|
||||
InvalidServer = "Invalid server! please try again.";
|
||||
|
||||
InvalidURL = "Invalid URL!";
|
||||
|
||||
urlParameter = "Clicking on the notification will jump \nto this URL in the parameter";
|
||||
|
||||
copyParameter = "If the URL has a copy parameter then the value of the copy \nparameter will be copied";
|
||||
|
||||
@ -11,13 +11,14 @@ SecureConnection = "HTTPS安全连接";
|
||||
InsecureConnection = "连接不安全,请使用HTTPS安全连接";
|
||||
RegisterDevice = "注册设备";
|
||||
|
||||
CustomedNotifictionContent = "这里改成你自己的推送内容";
|
||||
CustomedNotifictionTitle = "推送标题";
|
||||
CustomedNotificationContent = "这里改成你自己的推送内容";
|
||||
CustomedNotificationTitle = "推送标题";
|
||||
|
||||
Notice1 = "点击右上角按钮可以复制测试URL、预览推送效果\nSafari有缓存,没收到推送时请刷新页面";
|
||||
Notice2 = "推送标题的字号比推送内容粗一点";
|
||||
|
||||
Copy = "复制成功";
|
||||
Copy2 = "复制";
|
||||
|
||||
AllowNotifications = "绑定设备需要推送。请打开推送后重试";
|
||||
|
||||
@ -38,3 +39,7 @@ AddedSuccessfully = "修改成功!";
|
||||
InvalidServer = "填写的服务器无效,请重试!";
|
||||
|
||||
InvalidURL = "输入的URL好像不对劲!";
|
||||
|
||||
urlParameter = "携带url参数时,点击推送会跳转到这个URL";
|
||||
|
||||
copyParameter = "下拉推送、锁屏界面左滑查看推送时,可以选择复制推送内容\n携带copy参数时,将只复制copy参数的值";
|
||||
|
||||
@ -32,12 +32,23 @@ class HomeViewController: BaseViewController {
|
||||
var dataSource:[PreviewModel] = {
|
||||
return [
|
||||
PreviewModel(
|
||||
body: NSLocalizedString("CustomedNotifictionContent"),
|
||||
body: NSLocalizedString("CustomedNotificationContent"),
|
||||
notice: NSLocalizedString("Notice1")),
|
||||
PreviewModel(
|
||||
title: NSLocalizedString("CustomedNotifictionTitle"),
|
||||
body: NSLocalizedString("CustomedNotifictionContent"),
|
||||
notice: NSLocalizedString("Notice2"))
|
||||
title: NSLocalizedString("CustomedNotificationTitle"),
|
||||
body: NSLocalizedString("CustomedNotificationContent"),
|
||||
notice: NSLocalizedString("Notice2")),
|
||||
PreviewModel(
|
||||
body: "URL Test",
|
||||
notice: NSLocalizedString("urlParameter"),
|
||||
queryParameter: "url=https://www.baidu.com"
|
||||
),
|
||||
PreviewModel(
|
||||
body: "Copy Test",
|
||||
notice: NSLocalizedString("copyParameter"),
|
||||
queryParameter: "copy=test",
|
||||
image: UIImage(named: "copyTest")
|
||||
)
|
||||
]
|
||||
}()
|
||||
|
||||
@ -85,6 +96,20 @@ class HomeViewController: BaseViewController {
|
||||
refreshState()
|
||||
}
|
||||
}
|
||||
|
||||
let rowheight:[CGFloat] = {
|
||||
let screenWidth = UIScreen.main.bounds.width
|
||||
if screenWidth <= 320 {
|
||||
return [170,170,170,320]
|
||||
}
|
||||
if screenWidth <= 375 {
|
||||
return [205,205,205,380]
|
||||
}
|
||||
if screenWidth <= 414 {
|
||||
return [195,195,195,390]
|
||||
}
|
||||
return [205,205,205,380]
|
||||
}()
|
||||
}
|
||||
|
||||
extension HomeViewController : UITableViewDataSource, UITableViewDelegate {
|
||||
@ -92,11 +117,13 @@ extension HomeViewController : UITableViewDataSource, UITableViewDelegate {
|
||||
return dataSource.count
|
||||
}
|
||||
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
||||
return 200
|
||||
return rowheight[indexPath.row]
|
||||
}
|
||||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell = self.tableView.dequeueReusableCell(withIdentifier: "\(PreviewCardCell.self)", for: indexPath) as! PreviewCardCell
|
||||
cell.bind(model: dataSource[indexPath.row])
|
||||
if let cell = tableView.dequeueReusableCell(withIdentifier: "\(indexPath.row)") {
|
||||
return cell
|
||||
}
|
||||
let cell = PreviewCardCell(style: .default, reuseIdentifier: "\(indexPath.row)", model:dataSource[indexPath.row])
|
||||
cell.copyHandler = {[weak self] in
|
||||
self?.showSnackbar(text: NSLocalizedString("Copy"))
|
||||
}
|
||||
|
||||
@ -14,12 +14,16 @@ class PreviewModel: NSObject {
|
||||
var body:String?
|
||||
var category:String?
|
||||
var notice:String?
|
||||
var queryParameter:String?
|
||||
var image:UIImage?
|
||||
|
||||
init(title:String? = nil, body:String? = nil, category:String? = nil, notice:String? = nil) {
|
||||
init(title:String? = nil, body:String? = nil, category:String? = nil, notice:String? = nil, queryParameter:String? = nil, image:UIImage? = nil) {
|
||||
self.title = title
|
||||
self.body = body
|
||||
self.category = category
|
||||
self.notice = notice
|
||||
self.queryParameter = queryParameter
|
||||
self.image = image
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +43,7 @@ class PreviewCardCell: UITableViewCell {
|
||||
|
||||
let bottomBar = Bar()
|
||||
|
||||
let card = Card()
|
||||
let card = PresenterCard()
|
||||
|
||||
var copyHandler: (() -> Void)?
|
||||
|
||||
@ -50,7 +54,7 @@ class PreviewCardCell: UITableViewCell {
|
||||
return label
|
||||
}()
|
||||
|
||||
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
|
||||
init(style: UITableViewCellStyle, reuseIdentifier: String?, model:PreviewModel) {
|
||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||
self.selectionStyle = .none
|
||||
self.backgroundColor = Color.grey.lighten3
|
||||
@ -78,7 +82,8 @@ class PreviewCardCell: UITableViewCell {
|
||||
card.bottomBar = bottomBar
|
||||
card.bottomBarEdgeInsetsPreset = .wideRectangle2
|
||||
|
||||
self.layout(card).horizontally(left: 10, right: 10).top(40)
|
||||
self.bind(model: model)
|
||||
self.contentView.layout(card).horizontally(left: 10, right: 10).center()
|
||||
|
||||
previewButton.addTarget(self, action: #selector(preview), for: .touchUpInside)
|
||||
copyButton.addTarget(self, action: #selector(copyURL), for: .touchUpInside)
|
||||
@ -149,8 +154,26 @@ class PreviewCardCell: UITableViewCell {
|
||||
self.toolbar.detail = body
|
||||
}
|
||||
}
|
||||
if let queryParameter = model.queryParameter {
|
||||
attrStr.append(NSAttributedString(string: "?\(queryParameter)", attributes: [
|
||||
NSAttributedStringKey.foregroundColor: Color.grey.lighten1,
|
||||
NSAttributedStringKey.font : RobotoFont.regular(with: fontSize)
|
||||
]))
|
||||
}
|
||||
self.contentLabel.attributedText = attrStr
|
||||
self.noticeLabel.text = model.notice
|
||||
|
||||
if let image = model.image {
|
||||
let imageView = UIImageView(image: image)
|
||||
imageView.backgroundColor = UIColor.red
|
||||
imageView.contentMode = .scaleAspectFit
|
||||
let width = UIScreen.main.bounds.size.width - 20
|
||||
imageView.frame = CGRect(x: 0, y: 0, width: 0, height: width / image.width * image.height)
|
||||
|
||||
|
||||
card.presenterView = imageView
|
||||
card.presenterViewEdgeInsetsPreset = .none
|
||||
}
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14269.12" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="M4Y-Lb-cyx">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14252.5"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Notification View Controller-->
|
||||
<scene sceneID="cwh-vc-ff4">
|
||||
<objects>
|
||||
<viewController id="M4Y-Lb-cyx" userLabel="Notification View Controller" customClass="NotificationViewController" customModule="NotificationContentExtension" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" simulatedAppContext="notificationCenter" id="S3S-Oj-5AN">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="37"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<viewLayoutGuide key="safeArea" id="2BE-c3-nQJ"/>
|
||||
</view>
|
||||
<extendedEdge key="edgesForExtendedLayout"/>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<size key="freeformSize" width="320" height="37"/>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="vXp-U4-Rya" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
41
notificationContentExtension/Info.plist
Normal file
41
notificationContentExtension/Info.plist
Normal file
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>NotificationContentExtension</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionAttributes</key>
|
||||
<dict>
|
||||
<key>UNNotificationExtensionCategory</key>
|
||||
<array>
|
||||
<string>copy</string>
|
||||
<string>myNotificationCategory</string>
|
||||
</array>
|
||||
<key>UNNotificationExtensionInitialContentSizeRatio</key>
|
||||
<real>0.01</real>
|
||||
</dict>
|
||||
<key>NSExtensionMainStoryboard</key>
|
||||
<string>MainInterface</string>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.usernotifications.content-extension</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@ -0,0 +1,53 @@
|
||||
//
|
||||
// NotificationViewController.swift
|
||||
// NotificationContentExtension
|
||||
//
|
||||
// Created by huangfeng on 2018/7/4.
|
||||
// Copyright © 2018 Fin. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import UserNotifications
|
||||
import UserNotificationsUI
|
||||
|
||||
class NotificationViewController: UIViewController, UNNotificationContentExtension {
|
||||
|
||||
let noticeLabel:UILabel = {
|
||||
let label = UILabel()
|
||||
label.textColor = UIColor.black
|
||||
label.text = "复制完成!"
|
||||
label.font = UIFont.systemFont(ofSize: 16)
|
||||
label.textAlignment = .center
|
||||
return label
|
||||
}()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.view.addSubview(self.noticeLabel)
|
||||
self.preferredContentSize = CGSize(width: 0, height: 1)
|
||||
}
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
}
|
||||
|
||||
func didReceive(_ notification: UNNotification) {
|
||||
|
||||
}
|
||||
func didReceive(_ response: UNNotificationResponse, completionHandler completion: @escaping (UNNotificationContentExtensionResponseOption) -> Void) {
|
||||
|
||||
let userInfo = response.notification.request.content.userInfo
|
||||
|
||||
if let copy = userInfo["copy"] as? String {
|
||||
UIPasteboard.general.string = copy
|
||||
}
|
||||
else{
|
||||
UIPasteboard.general.string = response.notification.request.content.body
|
||||
}
|
||||
|
||||
self.preferredContentSize = CGSize(width: 0, height: 40)
|
||||
self.noticeLabel.frame = CGRect(x: 0, y: 0, width: self.view.bounds.width, height: 40)
|
||||
|
||||
completion(.doNotDismiss)
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user