Pārlūkot izejas kodu

友盟推送加cocoapods

南鑫林 5 gadi atpakaļ
vecāks
revīzija
700da24ee8

+ 31 - 0
RainbowPlanet/NotificationService/Info.plist

@@ -0,0 +1,31 @@
+<?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>NotificationService</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</string>
+	<key>CFBundleVersion</key>
+	<string>1</string>
+	<key>NSExtension</key>
+	<dict>
+		<key>NSExtensionPointIdentifier</key>
+		<string>com.apple.usernotifications.service</string>
+		<key>NSExtensionPrincipalClass</key>
+		<string>$(PRODUCT_MODULE_NAME).NotificationService</string>
+	</dict>
+</dict>
+</plist>

+ 93 - 0
RainbowPlanet/NotificationService/NotificationService.swift

@@ -0,0 +1,93 @@
+//
+//  NotificationService.swift
+//  NotificationService
+//
+//  Created by 南鑫林 on 2019/9/10.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UserNotifications
+import UIKit
+
+class NotificationService: UNNotificationServiceExtension {
+
+    var contentHandler: ((UNNotificationContent) -> Void)?
+    var bestAttemptContent: UNMutableNotificationContent?
+
+    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
+        self.contentHandler = contentHandler
+        //[modified]这个是一个标示,可以实现对服务器下发下来的内容进行更改
+        bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
+        
+        func failEarly() {
+            contentHandler(request.content)
+        }
+        if let bestAttemptContent = bestAttemptContent {
+            let apsDic = request.content.userInfo["aps"] as? [AnyHashable : Any]
+            let attachUrl = apsDic?["image"] as? String
+            let category = apsDic?["category"] as? String
+            bestAttemptContent.categoryIdentifier = category ?? ""
+            let url = URL(string: attachUrl ?? "")
+            guard let imageData = NSData(contentsOf:url!) else { return failEarly() }
+            
+            let image = UIImage(data: imageData as Data)
+            let identifier = ProcessInfo.processInfo.globallyUniqueString
+            if let attachment = UNNotificationAttachment.create(identifier: identifier, image: image!, options: nil) {
+                // where myImage is any UIImage that follows the
+                bestAttemptContent.attachments = [attachment]
+            }
+            contentHandler(bestAttemptContent)
+        }
+    }
+    
+    override func serviceExtensionTimeWillExpire() {
+        // Called just before the extension will be terminated by the system.
+        // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
+        if let contentHandler = contentHandler, let bestAttemptContent =  bestAttemptContent {
+            contentHandler(bestAttemptContent)
+        }
+    }
+
+}
+
+extension UNNotificationAttachment {
+    
+    static func create(identifier: String, image: UIImage, options: [NSObject : AnyObject]?) -> UNNotificationAttachment? {
+        let fileManager = FileManager.default
+        let tmpSubFolderName = ProcessInfo.processInfo.globallyUniqueString
+        let tmpSubFolderURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(tmpSubFolderName, isDirectory: true)
+        do {
+            try fileManager.createDirectory(at: tmpSubFolderURL, withIntermediateDirectories: true, attributes: nil)
+            let imageFileIdentifier = identifier+".png"
+            let fileURL = tmpSubFolderURL.appendingPathComponent(imageFileIdentifier)
+            guard let imageData = image.pngData() else {
+                return nil
+            }
+            try imageData.write(to: fileURL)
+            let imageAttachment = try UNNotificationAttachment.init(identifier: imageFileIdentifier, url: fileURL, options: options)
+            return imageAttachment
+        } catch {
+            print("error " + error.localizedDescription)
+        }
+        return nil
+    }
+    
+    /// Save the image to disk
+    static func create(imageFileIdentifier: String, data: NSData, options: [NSObject : AnyObject]?) -> UNNotificationAttachment? {
+        let fileManager = FileManager.default
+        let tmpSubFolderName = ProcessInfo.processInfo.globallyUniqueString
+        let tmpSubFolderURL = NSURL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(tmpSubFolderName, isDirectory: true)
+        
+        do {
+            try fileManager.createDirectory(at: tmpSubFolderURL!, withIntermediateDirectories: true, attributes: nil)
+            let fileURL = tmpSubFolderURL?.appendingPathComponent(imageFileIdentifier)
+            try data.write(to: fileURL!, options: [])
+            let imageAttachment = try UNNotificationAttachment.init(identifier: imageFileIdentifier, url: fileURL!, options: options)
+            return imageAttachment
+        } catch let error {
+            print("error \(error)")
+        }
+        
+        return nil
+    }
+}

+ 16 - 16
RainbowPlanet/Podfile.lock

@@ -14,36 +14,36 @@ PODS:
   - AFNetworking/Serialization (3.2.1)
   - AFNetworking/UIKit (3.2.1):
     - AFNetworking/NSURLSession
-  - Alamofire (4.8.2)
-  - AlivcConan (0.9.5):
-    - AlivcConan/AlivcConan (= 0.9.5)
-  - AlivcConan/AlivcConan (0.9.5)
+  - Alamofire (4.9.0)
+  - AlivcConan (0.9.5.1):
+    - AlivcConan/AlivcConan (= 0.9.5.1)
+  - AlivcConan/AlivcConan (0.9.5.1)
   - AliyunOSSiOS (2.10.7)
   - AliyunVideoSDKPro (3.11.0)
   - BaiduMapKit (4.4.2)
   - BMKLocationKit (1.5.0)
   - Bugly (2.5.0)
   - Cache (5.2.0)
-  - DeviceKit (2.0.0)
+  - DeviceKit (2.1.0)
   - DPScrollNumberLabel (0.0.2)
   - ESTabBarController-swift (2.7)
   - FBRetainCycleDetector (0.1.4)
   - FMDB (2.7.5):
     - FMDB/standard (= 2.7.5)
   - FMDB/standard (2.7.5)
-  - FSPagerView (0.8.2)
+  - FSPagerView (0.8.3)
   - FWPopupView (4.0.7):
     - SnapKit
   - InputBarAccessoryView (4.3.1):
     - InputBarAccessoryView/Core (= 4.3.1)
   - InputBarAccessoryView/Core (4.3.1)
-  - IQKeyboardManagerSwift (6.4.1)
+  - IQKeyboardManagerSwift (6.4.2)
   - JSONModel (1.7.0)
   - JXSegmentedView (0.0.19)
   - KeychainAccess (3.2.0)
   - Kingfisher (4.10.1)
   - lottie-ios (3.1.2)
-  - LYEmptyView (1.2.5)
+  - LYEmptyView (1.3.0)
   - Masonry (1.1.0)
   - MBProgressHUD (1.1.0)
   - MJRefresh (3.2.0)
@@ -88,7 +88,7 @@ PODS:
   - UMCShare/UI (6.9.6):
     - UMCCommon
     - UMCShare/Core
-  - VODUpload (1.5.1):
+  - VODUpload (1.5.3):
     - AliyunOSSiOS
   - WebViewJavascriptBridge (6.0.3)
   - YYText (1.0.7)
@@ -198,29 +198,29 @@ SPEC REPOS:
 
 SPEC CHECKSUMS:
   AFNetworking: b6f891fdfaed196b46c7a83cf209e09697b94057
-  Alamofire: ae5c501addb7afdbb13687d7f2f722c78734c2d3
-  AlivcConan: 9dccc32986024768bb5f50e14ad54490123903c7
+  Alamofire: afc3e7c6db61476cb45cdd23fed06bad03bbc321
+  AlivcConan: 7462cb9a4101b281dfa2434d251149c234424801
   AliyunOSSiOS: 602b6a4e70e62a5f0a6431c20496343141d7e66f
   AliyunVideoSDKPro: da710c1e7fb93b1e9a741b3619814c6608780b4b
   BaiduMapKit: 11acde2e7c06e31b7de60b323880a5eb7c4dccb6
   BMKLocationKit: 40d267478acd8704ddebd0e9deaddc727b13df9f
   Bugly: 3ca9f255c01025582df26f9222893b383c7e4b4e
   Cache: 807c5d86d01a177f06ede9865add3aea269bbfd4
-  DeviceKit: 72d36709552d4b3582abd76a53949148acad9811
+  DeviceKit: 2f6c28410d5a5fe2977be7f8cb9b313d28bdae69
   DPScrollNumberLabel: 5124eaccf3029bb84116de391e1273cba676f4f5
   ESTabBarController-swift: 4fb52ad03d94d0717ef97bc9eb09a5abfdded0a2
   FBRetainCycleDetector: 46f8179bbb1c587deee3ea838a1a3ee02acf5015
   FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
-  FSPagerView: 816a18842306973cc7cc6df8a5332272f7815c30
+  FSPagerView: 670405b2f18e2a87fa37f20b00de783e562c25a8
   FWPopupView: c1dbb33fbe4d223f619f28a7e5e5a00f08c10342
   InputBarAccessoryView: 58a348be7ea2736c7eec60e5c315511c2dbb39fd
-  IQKeyboardManagerSwift: d2df660d0b8d64a15cb2537c9ff303213fa515b2
+  IQKeyboardManagerSwift: 79a3ec200dfb41cb66a89b8575417b5378107c5d
   JSONModel: 840bc0fcffb24b8454d2c026bf26fea454b8e98d
   JXSegmentedView: 6e22381bd1e6f0767fc078bef1947b13b2d337a1
   KeychainAccess: 3b1bf8a77eb4c6ea1ce9404c292e48f948954c6b
   Kingfisher: c148cd7b47ebde9989f6bc7c27dcaa79d81279a0
   lottie-ios: 49cd85b1f24f61a7708ad7ec76a523ab2d0e3100
-  LYEmptyView: b17adfc2dd9ad2988ecaf7c9606efa916e24c767
+  LYEmptyView: bd85bfb78e943b30df3d34bcc2534f21b999938e
   Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
   MBProgressHUD: e7baa36a220447d8aeb12769bf0585582f3866d9
   MJRefresh: ed450d6eb9d3346a2cb033ab7eb6de090aeef437
@@ -241,7 +241,7 @@ SPEC CHECKSUMS:
   UMCPush: 1edd856027dcf905333effb4040ace5d236a7316
   UMCSecurityPlugins: 0831a08f3988f3cea9f1d3a7626cd9bee4fef150
   UMCShare: e0cef55c0fd6051254c8cda1d0630eb578b27bad
-  VODUpload: d180069b5fcee002079a892de2f310bacdb8e355
+  VODUpload: a76d07081e4faf9bd9e7535265901cde2cea507f
   WebViewJavascriptBridge: 7f5bc4d3581e672e8f32bd0f812d54bc69bb8e29
   YYText: 5c461d709e24d55a182d1441c41dc639a18a4849
   ZipArchive: e25a4373192673e3229ac8d6e9f64a3e5713c966

+ 141 - 1
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -155,6 +155,8 @@
 		A74322A422B8E7F60017C367 /* MyFollowAndFanHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A74322A322B8E7F60017C367 /* MyFollowAndFanHeaderView.swift */; };
 		A74322A922B900180017C367 /* CommunityFindFriendsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A74322A822B900180017C367 /* CommunityFindFriendsViewController.swift */; };
 		A74322AB22B900F00017C367 /* CommunityFindFriendsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A74322AA22B900F00017C367 /* CommunityFindFriendsView.swift */; };
+		A74D9D572327B54100F05C14 /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A74D9D562327B54100F05C14 /* NotificationService.swift */; };
+		A74D9D5B2327B54100F05C14 /* NotificationService.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = A74D9D542327B54100F05C14 /* NotificationService.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
 		A74DF74922EAAF17007FB505 /* MJDIYFullScreenHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = A74DF74822EAAF17007FB505 /* MJDIYFullScreenHeader.swift */; };
 		A74DF74D22EAEF60007FB505 /* MJRefreshManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A74DF74C22EAEF60007FB505 /* MJRefreshManager.swift */; };
 		A75414FD224B5F28002480B5 /* MobileLoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A75414FB224B5F28002480B5 /* MobileLoginViewController.swift */; };
@@ -588,6 +590,13 @@
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
+		A74D9D592327B54100F05C14 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = A77F2C552231FB49001BD3F6 /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = A74D9D532327B54100F05C14;
+			remoteInfo = NotificationService;
+		};
 		A77F2C722231FB4A001BD3F6 /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
 			containerPortal = A77F2C552231FB49001BD3F6 /* Project object */;
@@ -604,6 +613,20 @@
 		};
 /* End PBXContainerItemProxy section */
 
+/* Begin PBXCopyFilesBuildPhase section */
+		A74D9D5F2327B54100F05C14 /* Embed App Extensions */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 2147483647;
+			dstPath = "";
+			dstSubfolderSpec = 13;
+			files = (
+				A74D9D5B2327B54100F05C14 /* NotificationService.appex in Embed App Extensions */,
+			);
+			name = "Embed App Extensions";
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXCopyFilesBuildPhase section */
+
 /* Begin PBXFileReference section */
 		57C497E128081597F165C771 /* Pods-RainbowPlanet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RainbowPlanet.release.xcconfig"; path = "Pods/Target Support Files/Pods-RainbowPlanet/Pods-RainbowPlanet.release.xcconfig"; sourceTree = "<group>"; };
 		88DF1EFD2E202DA7C627E8A7 /* Pods_RainbowPlanetUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RainbowPlanetUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -761,6 +784,9 @@
 		A74322A322B8E7F60017C367 /* MyFollowAndFanHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyFollowAndFanHeaderView.swift; sourceTree = "<group>"; };
 		A74322A822B900180017C367 /* CommunityFindFriendsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityFindFriendsViewController.swift; sourceTree = "<group>"; };
 		A74322AA22B900F00017C367 /* CommunityFindFriendsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityFindFriendsView.swift; sourceTree = "<group>"; };
+		A74D9D542327B54100F05C14 /* NotificationService.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = NotificationService.appex; sourceTree = BUILT_PRODUCTS_DIR; };
+		A74D9D562327B54100F05C14 /* NotificationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationService.swift; sourceTree = "<group>"; };
+		A74D9D582327B54100F05C14 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		A74DF74822EAAF17007FB505 /* MJDIYFullScreenHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MJDIYFullScreenHeader.swift; sourceTree = "<group>"; };
 		A74DF74C22EAEF60007FB505 /* MJRefreshManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MJRefreshManager.swift; sourceTree = "<group>"; };
 		A75414FB224B5F28002480B5 /* MobileLoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MobileLoginViewController.swift; sourceTree = "<group>"; };
@@ -1268,6 +1294,13 @@
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
+		A74D9D512327B54100F05C14 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		A77F2C5A2231FB49001BD3F6 /* Frameworks */ = {
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
@@ -2211,6 +2244,15 @@
 			path = View;
 			sourceTree = "<group>";
 		};
+		A74D9D552327B54100F05C14 /* NotificationService */ = {
+			isa = PBXGroup;
+			children = (
+				A74D9D562327B54100F05C14 /* NotificationService.swift */,
+				A74D9D582327B54100F05C14 /* Info.plist */,
+			);
+			path = NotificationService;
+			sourceTree = "<group>";
+		};
 		A74DF74B22EAEF43007FB505 /* MJRefreshManager */ = {
 			isa = PBXGroup;
 			children = (
@@ -2580,6 +2622,7 @@
 				A77F2C5F2231FB49001BD3F6 /* RainbowPlanet */,
 				A77F2C742231FB4A001BD3F6 /* RainbowPlanetTests */,
 				A77F2C7F2231FB4A001BD3F6 /* RainbowPlanetUITests */,
+				A74D9D552327B54100F05C14 /* NotificationService */,
 				A77F2C5E2231FB49001BD3F6 /* Products */,
 				618631008656829220117ED1 /* Pods */,
 				FA8AAFBADE8BD144A5C36FDB /* Frameworks */,
@@ -2592,6 +2635,7 @@
 				A77F2C5D2231FB49001BD3F6 /* RainbowPlanet.app */,
 				A77F2C712231FB4A001BD3F6 /* RainbowPlanetTests.xctest */,
 				A77F2C7C2231FB4A001BD3F6 /* RainbowPlanetUITests.xctest */,
+				A74D9D542327B54100F05C14 /* NotificationService.appex */,
 			);
 			name = Products;
 			sourceTree = "<group>";
@@ -4911,6 +4955,23 @@
 /* End PBXGroup section */
 
 /* Begin PBXNativeTarget section */
+		A74D9D532327B54100F05C14 /* NotificationService */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = A74D9D5E2327B54100F05C14 /* Build configuration list for PBXNativeTarget "NotificationService" */;
+			buildPhases = (
+				A74D9D502327B54100F05C14 /* Sources */,
+				A74D9D512327B54100F05C14 /* Frameworks */,
+				A74D9D522327B54100F05C14 /* Resources */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = NotificationService;
+			productName = NotificationService;
+			productReference = A74D9D542327B54100F05C14 /* NotificationService.appex */;
+			productType = "com.apple.product-type.app-extension";
+		};
 		A77F2C5C2231FB49001BD3F6 /* RainbowPlanet */ = {
 			isa = PBXNativeTarget;
 			buildConfigurationList = A77F2C852231FB4A001BD3F6 /* Build configuration list for PBXNativeTarget "RainbowPlanet" */;
@@ -4921,10 +4982,12 @@
 				A77F2C5B2231FB49001BD3F6 /* Resources */,
 				696EB1DDE9DE019617B4DAD7 /* [CP] Embed Pods Frameworks */,
 				59501F6F4334279DFBD164A0 /* [CP] Copy Pods Resources */,
+				A74D9D5F2327B54100F05C14 /* Embed App Extensions */,
 			);
 			buildRules = (
 			);
 			dependencies = (
+				A74D9D5A2327B54100F05C14 /* PBXTargetDependency */,
 			);
 			name = RainbowPlanet;
 			productName = RainbowPlanet;
@@ -4973,10 +5036,13 @@
 		A77F2C552231FB49001BD3F6 /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
-				LastSwiftUpdateCheck = 1010;
+				LastSwiftUpdateCheck = 1030;
 				LastUpgradeCheck = 1010;
 				ORGANIZATIONNAME = RainbowPlanet;
 				TargetAttributes = {
+					A74D9D532327B54100F05C14 = {
+						CreatedOnToolsVersion = 10.3;
+					};
 					A77F2C5C2231FB49001BD3F6 = {
 						CreatedOnToolsVersion = 10.1;
 						LastSwiftMigration = 1020;
@@ -5017,11 +5083,19 @@
 				A77F2C5C2231FB49001BD3F6 /* RainbowPlanet */,
 				A77F2C702231FB4A001BD3F6 /* RainbowPlanetTests */,
 				A77F2C7B2231FB4A001BD3F6 /* RainbowPlanetUITests */,
+				A74D9D532327B54100F05C14 /* NotificationService */,
 			);
 		};
 /* End PBXProject section */
 
 /* Begin PBXResourcesBuildPhase section */
+		A74D9D522327B54100F05C14 /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		A77F2C5B2231FB49001BD3F6 /* Resources */ = {
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
@@ -5140,6 +5214,14 @@
 /* End PBXShellScriptBuildPhase section */
 
 /* Begin PBXSourcesBuildPhase section */
+		A74D9D502327B54100F05C14 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				A74D9D572327B54100F05C14 /* NotificationService.swift in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
 		A77F2C592231FB49001BD3F6 /* Sources */ = {
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
@@ -5693,6 +5775,11 @@
 /* End PBXSourcesBuildPhase section */
 
 /* Begin PBXTargetDependency section */
+		A74D9D5A2327B54100F05C14 /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = A74D9D532327B54100F05C14 /* NotificationService */;
+			targetProxy = A74D9D592327B54100F05C14 /* PBXContainerItemProxy */;
+		};
 		A77F2C732231FB4A001BD3F6 /* PBXTargetDependency */ = {
 			isa = PBXTargetDependency;
 			target = A77F2C5C2231FB49001BD3F6 /* RainbowPlanet */;
@@ -5706,6 +5793,48 @@
 /* End PBXTargetDependency section */
 
 /* Begin XCBuildConfiguration section */
+		A74D9D5C2327B54100F05C14 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				CODE_SIGN_IDENTITY = "iPhone Developer";
+				CODE_SIGN_STYLE = Automatic;
+				DEVELOPMENT_TEAM = C6GA87VLB8;
+				INFOPLIST_FILE = NotificationService/Info.plist;
+				IPHONEOS_DEPLOYMENT_TARGET = 12.4;
+				LD_RUNPATH_SEARCH_PATHS = (
+					"$(inherited)",
+					"@executable_path/Frameworks",
+					"@executable_path/../../Frameworks",
+				);
+				PRODUCT_BUNDLE_IDENTIFIER = com.uptoyo.uptoyo.NotificationService;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SKIP_INSTALL = YES;
+				SWIFT_VERSION = 5.0;
+				TARGETED_DEVICE_FAMILY = "1,2";
+			};
+			name = Debug;
+		};
+		A74D9D5D2327B54100F05C14 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				CODE_SIGN_IDENTITY = "iPhone Developer";
+				CODE_SIGN_STYLE = Automatic;
+				DEVELOPMENT_TEAM = C6GA87VLB8;
+				INFOPLIST_FILE = NotificationService/Info.plist;
+				IPHONEOS_DEPLOYMENT_TARGET = 12.4;
+				LD_RUNPATH_SEARCH_PATHS = (
+					"$(inherited)",
+					"@executable_path/Frameworks",
+					"@executable_path/../../Frameworks",
+				);
+				PRODUCT_BUNDLE_IDENTIFIER = com.uptoyo.uptoyo.NotificationService;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				SKIP_INSTALL = YES;
+				SWIFT_VERSION = 5.0;
+				TARGETED_DEVICE_FAMILY = "1,2";
+			};
+			name = Release;
+		};
 		A77F2C832231FB4A001BD3F6 /* Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
@@ -5828,6 +5957,7 @@
 			isa = XCBuildConfiguration;
 			baseConfigurationReference = BD9052C044FD3AE4E62D3929 /* Pods-RainbowPlanet.debug.xcconfig */;
 			buildSettings = {
+				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_ENTITLEMENTS = "RainbowPlanet/Supporting Files/RainbowPlanet.entitlements";
@@ -6077,6 +6207,7 @@
 			isa = XCBuildConfiguration;
 			baseConfigurationReference = 57C497E128081597F165C771 /* Pods-RainbowPlanet.release.xcconfig */;
 			buildSettings = {
+				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_ENTITLEMENTS = "RainbowPlanet/Supporting Files/RainbowPlanet.entitlements";
@@ -6411,6 +6542,15 @@
 /* End XCBuildConfiguration section */
 
 /* Begin XCConfigurationList section */
+		A74D9D5E2327B54100F05C14 /* Build configuration list for PBXNativeTarget "NotificationService" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				A74D9D5C2327B54100F05C14 /* Debug */,
+				A74D9D5D2327B54100F05C14 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
 		A77F2C582231FB49001BD3F6 /* Build configuration list for PBXProject "RainbowPlanet" */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (

+ 4 - 0
RainbowPlanet/RainbowPlanet/Model/PushModel/PushModel.swift

@@ -12,11 +12,15 @@ import ObjectMapper
 /// - post: 跳转到帖子详情
 /// - recommend: 跳转到推荐首页
 /// - star:  跳转到星球首页
+/// - activity:  跳转到活动详情
+/// - product:   跳转到商品详情
 enum PushActionType : String {
     case none = ""
     case post = "post"
     case recommend = "recommend"
     case star = "star"
+    case activity = "activity"
+    case product = "product"
 }
 
 class PushModel : NSObject, Mappable{

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/Community/View/Cell/CardContent/PicVideo/CardContentPicVideoTableViewCell.swift

@@ -130,7 +130,7 @@ class CardContentPicVideoTableViewCell: UITableViewCell {
                 make.top.equalToSuperview()
                 make.left.equalTo(14)
                 make.right.equalTo(-14)
-                make.bottom.equalTo(-20)
+                make.bottom.equalTo(-15)
             }
             collectionView.reloadData()
         }

+ 3 - 3
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/Community/ViewController/Follow/CommunityFollowViewController.swift

@@ -586,7 +586,7 @@ extension CommunityFollowViewController : UITableViewDelegate,UITableViewDataSou
                     cardContentPicVideoModel.number = 1
                     cardContentPicVideoModel.width = getImageWidth(imgStr: (imgStr)!)
                     cardContentPicVideoModel.height = getImageHeight(imgStr: (imgStr)!)
-                    return cardContentPicVideoModel.collectionViewHeight() + 20
+                    return cardContentPicVideoModel.collectionViewHeight() + 15
                 }else {
                     return 0
                 }
@@ -596,13 +596,13 @@ extension CommunityFollowViewController : UITableViewDelegate,UITableViewDataSou
                         cardContentPicVideoModel.number = 1
                         cardContentPicVideoModel.width = getImageWidth(imgStr: (imgStr)!)
                         cardContentPicVideoModel.height = getImageHeight(imgStr: (imgStr)!)
-                        return cardContentPicVideoModel.collectionViewHeight() + 20
+                        return cardContentPicVideoModel.collectionViewHeight() + 15
                     }else {
                         return 0
                     }
                 }else {
                     cardContentPicVideoModel.number = communityFollowDataModel?.relateData?.imgs?.count ?? 0
-                    return cardContentPicVideoModel.collectionViewHeight() + 20
+                    return cardContentPicVideoModel.collectionViewHeight() + 15
                 }
             }
         //内容标题

+ 3 - 3
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityFeaturedTopics/ViewController/CommunityFeaturedTopicsViewController.swift

@@ -517,7 +517,7 @@ extension CommunityFeaturedTopicsViewController : UITableViewDelegate,UITableVie
                     cardContentPicVideoModel.number = 1
                     cardContentPicVideoModel.width = getImageWidth(imgStr: (imgStr)!)
                     cardContentPicVideoModel.height = getImageHeight(imgStr: (imgStr)!)
-                    return cardContentPicVideoModel.collectionViewHeight() + 20
+                    return cardContentPicVideoModel.collectionViewHeight() + 15
                 }else {
                     return 0
                 }
@@ -527,13 +527,13 @@ extension CommunityFeaturedTopicsViewController : UITableViewDelegate,UITableVie
                         cardContentPicVideoModel.number = 1
                         cardContentPicVideoModel.width = getImageWidth(imgStr: (imgStr)!)
                         cardContentPicVideoModel.height = getImageHeight(imgStr: (imgStr)!)
-                        return cardContentPicVideoModel.collectionViewHeight() + 20
+                        return cardContentPicVideoModel.collectionViewHeight() + 15
                     }else {
                         return 0
                     }
                 }else {
                     cardContentPicVideoModel.number = communityRecommendDataModel.imgs?.count ?? 0
-                    return cardContentPicVideoModel.collectionViewHeight() + 20
+                    return cardContentPicVideoModel.collectionViewHeight() + 15
                 }
             }
         //内容标题

+ 5 - 0
RainbowPlanet/RainbowPlanet/Router/RouterManager.swift

@@ -81,6 +81,11 @@ class RouterManager: NSObject {
             } else {
                 vc?.navigationController?.popToRootViewController(animated: false)
             }
+        case .activity?: //活动
+            Mediator.push(H5RouterModuleType.pushActivityId(id: "\(pushModel.actionId ?? 0)"))
+            break
+        case .product?: //商品
+            Mediator.push(H5RouterModuleType.pushDetail(id: "\(pushModel.actionId ?? 0)"))
             break
         case .none?:
             break

+ 38 - 2
RainbowPlanet/RainbowPlanet/ViewModel/UserMemberTotalBeanViewModel/UserMemberTotalBeanViewModel.swift

@@ -11,10 +11,20 @@ import RxSwift
 
 class UserMemberTotalBeanViewModel: NSObject {
     
+    deinit {
+        if observe != nil {
+            NotificationCenter.default.removeObserver(observe!)
+        }
+    }
+    weak var observe : NSObjectProtocol?
+    
     let disposeBag = DisposeBag()
     
     static let shared : UserMemberTotalBeanViewModel = UserMemberTotalBeanViewModel()
     
+    private var isBackstage : Bool? = true
+    
+    
     func userMemberGetTotalBeanApi() {
         if UserModel.shared().getModel()?.token != nil {
             SwiftMoyaNetWorkServiceUser.shared().userMemberGetTotalBeanApi(completion: { (totalBeanModel) -> (Void) in
@@ -24,8 +34,9 @@ class UserMemberTotalBeanViewModel: NSObject {
     }
     
     func userMemberGetTotalBeanApiInterval() {
-        Observable<Int>.interval(60, scheduler: MainScheduler.instance).subscribe(onNext: { _ in
-            if UserModel.shared().getModel()?.token != nil && (UserModel.shared().getModel()?.isFollowSuggestTopic != nil || UserModel.shared().getModel()?.isFollowSuggestTopic != 0) {
+        application()
+        Observable<Int>.interval(60, scheduler: MainScheduler.instance).subscribe(onNext: { [weak self] _ in
+            if UserModel.shared().getModel()?.token != nil && (UserModel.shared().getModel()?.isFollowSuggestTopic != nil || UserModel.shared().getModel()?.isFollowSuggestTopic != 0) && (self?.isBackstage)! {
                 SwiftMoyaNetWorkServiceUser.shared().userMemberGetTotalBeanApi(completion: { (totalBeanModel) -> (Void) in
                     NotificationCenter.default.post(name: NSNotification.Name(rawValue: "userMemberGetTotalBean"), object: totalBeanModel)
                     
@@ -34,4 +45,29 @@ class UserMemberTotalBeanViewModel: NSObject {
         }).disposed(by: disposeBag)
     }
     
+    func application() {
+        //启动程序
+        observe = NotificationCenter.default.addObserver(forName: UIApplication.didFinishLaunchingNotification, object: nil, queue: OperationQueue.main, using: {
+            [weak self] (notification) in
+            self?.isBackstage = true
+        })
+        //程序进入后台
+        observe = NotificationCenter.default.addObserver(forName: UIApplication.didEnterBackgroundNotification, object: nil, queue: OperationQueue.main, using: {
+            [weak self] (notification) in
+            self?.isBackstage = false
+        })
+        //将要进入前台的时候
+        observe = NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: OperationQueue.main, using: {
+            [weak self] (notification) in
+           self?.isBackstage = true
+           self?.userMemberGetTotalBeanApi()
+        })
+    }
+    
+   
+    
+    
+    
+    
+    
 }