alqindiirsyam il y a 2 ans
Parent
commit
4496613e9c

+ 2 - 2
appbuilder-ios/AppBuilder/AppBuilder.xcodeproj/project.pbxproj

@@ -445,7 +445,7 @@
 					"$(inherited)",
 					"@executable_path/Frameworks",
 				);
-				MARKETING_VERSION = 2.2.6;
+				MARKETING_VERSION = 2.2.8;
 				PRODUCT_BUNDLE_IDENTIFIER = io.newuniverse.AppBuilder1;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PROVISIONING_PROFILE_SPECIFIER = "";
@@ -476,7 +476,7 @@
 					"$(inherited)",
 					"@executable_path/Frameworks",
 				);
-				MARKETING_VERSION = 2.2.6;
+				MARKETING_VERSION = 2.2.8;
 				PRODUCT_BUNDLE_IDENTIFIER = io.newuniverse.AppBuilder1;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PROVISIONING_PROFILE_SPECIFIER = "";

+ 104 - 1
appbuilder-ios/AppBuilder/AppBuilder/AppDelegate.swift

@@ -198,11 +198,29 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
         tMessage.mBodies[CoreMessage_TMessageKey.KEY] = key
         return tMessage
     }
+    
+    private func registerForPushNotifications() {
+        if #available(iOS 10.0, *) {
+            let center  = UNUserNotificationCenter.current()
+            center.delegate = self
+            center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
+                if error == nil{
+                    DispatchQueue.main.async {
+                        UIApplication.shared.registerForRemoteNotifications()
+                    }
+                }
+            }
+        }
+        else {
+            UIApplication.shared.registerUserNotificationSettings(UIUserNotificationSettings(types: [.sound, .alert, .badge], categories: nil))
+            UIApplication.shared.registerForRemoteNotifications()
+        }
+    }
 
 
 }
 
-extension AppDelegate: ConnectDelegate {
+extension AppDelegate: ConnectDelegate, UNUserNotificationCenterDelegate {
     
     func onSuccess(userId: String) {
         print(#function, "userId: \(userId)")
@@ -212,5 +230,90 @@ extension AppDelegate: ConnectDelegate {
         print(#function, "error: \(error)")
     }
     
+    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
+        let deviceTokenString = deviceToken.map { String(format: "%02x", $0) }.joined()
+        print("TOKEN: \(deviceTokenString)")
+    }
+    
+    func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
+        print(error)
+    }
+    
+    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
+        let userInfo = response.notification.request.content.userInfo
+        if let opposite = userInfo["opposite"] as? String {
+            let user = User.getDataCanNil(pin: opposite)
+            if user != nil {
+                openEditorPersonal(opposite: opposite)
+            } else {
+                let group = Group.getData(group_id: opposite)
+                let topic = Topic.getData(topic_id: opposite)
+                if group != nil || topic != nil {
+                    openEditorGroup(opposite: opposite)
+                }
+            }
+        }
+        UIApplication.shared.applicationIconBadgeNumber = 0
+        UNUserNotificationCenter.current().removeAllDeliveredNotifications()
+        completionHandler()
+    }
+    
+    func openEditorPersonal(opposite: String) {
+        let editorPersonalVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorPersonalVC") as! EditorPersonal
+        editorPersonalVC.hidesBottomBarWhenPushed = true
+        editorPersonalVC.unique_l_pin = opposite
+        editorPersonalVC.fromNotification = true
+        let onGoingCC = UserDefaults.standard.string(forKey: "onGoingCC") ?? ""
+        if !onGoingCC.isEmpty {
+            let compalintId = onGoingCC.components(separatedBy: ",")[2]
+            let fPinCC = onGoingCC.isEmpty ? "" : onGoingCC.components(separatedBy: ",")[1]
+            editorPersonalVC.isContactCenter = true
+            editorPersonalVC.fPinContacCenter = fPinCC
+            editorPersonalVC.complaintId = compalintId
+            editorPersonalVC.onGoingCC = true
+            editorPersonalVC.isRequestContactCenter = false
+        }
+        let navigationController = UINavigationController(rootViewController: editorPersonalVC)
+        navigationController.modalPresentationStyle = .fullScreen
+        navigationController.navigationBar.tintColor = .white
+        navigationController.navigationBar.barTintColor = .mainColor
+        navigationController.navigationBar.isTranslucent = false
+        navigationController.navigationBar.overrideUserInterfaceStyle = .dark
+        navigationController.navigationBar.barStyle = .black
+        let cancelButtonAttributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.foregroundColor: UIColor.white]
+        UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
+        let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
+        navigationController.navigationBar.titleTextAttributes = textAttributes
+        navigationController.view.backgroundColor = .mainColor
+        if UIApplication.shared.visibleViewController?.navigationController != nil {
+            UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
+        } else {
+            UIApplication.shared.visibleViewController?.present(navigationController, animated: true, completion: nil)
+        }
+    }
+    
+    func openEditorGroup(opposite: String) {
+        let editorGroupVC = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "editorGroupVC") as! EditorGroup
+        editorGroupVC.hidesBottomBarWhenPushed = true
+        editorGroupVC.unique_l_pin = opposite
+        editorGroupVC.fromNotification = true
+        let navigationController = UINavigationController(rootViewController: editorGroupVC)
+        navigationController.modalPresentationStyle = .fullScreen
+        navigationController.navigationBar.tintColor = .white
+        navigationController.navigationBar.barTintColor = .mainColor
+        navigationController.navigationBar.isTranslucent = false
+        navigationController.navigationBar.overrideUserInterfaceStyle = .dark
+        navigationController.navigationBar.barStyle = .black
+        let cancelButtonAttributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.foregroundColor: UIColor.white]
+        UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
+        let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
+        navigationController.navigationBar.titleTextAttributes = textAttributes
+        navigationController.view.backgroundColor = .mainColor
+        if UIApplication.shared.visibleViewController?.navigationController != nil {
+            UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
+        } else {
+            UIApplication.shared.visibleViewController?.present(navigationController, animated: true, completion: nil)
+        }
+    }
 }
 

+ 4 - 0
appbuilder-ios/AppBuilder/AppBuilder/Info.plist

@@ -2,6 +2,10 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
+	<key>BGTaskSchedulerPermittedIdentifiers</key>
+	<array>
+		<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+	</array>
 	<key>CFBundleDevelopmentRegion</key>
 	<string>$(DEVELOPMENT_LANGUAGE)</string>
 	<key>CFBundleDisplayName</key>

+ 1 - 0
appbuilder-ios/AppBuilder/AppBuilder/ViewController.swift

@@ -968,6 +968,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
             DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .seconds(1), execute: {
                 let me = UserDefaults.standard.string(forKey: "me")
                 let address = "\(PrefsUtil.getURLBase())nexilis/pages/tab5-new-post?f_pin=\(me ?? "")"
+                self.thirdTab?.webView.evaluateJavaScript("{window.localStorage.setItem('currentTab','\(ViewController.tab3)')}")
                 self.thirdTab?.webView.evaluateJavaScript("window.location = '\(address)'")
                 
             })

+ 38 - 1
appbuilder-ios/NexilisLite/NexilisLite/Source/Model/Group.swift

@@ -58,7 +58,28 @@ public class Group: Model {
         return lhs.id == rhs.id
     }
     
-    
+    public static func getData(group_id: String?) -> Group? {
+        guard let group_id = group_id else {
+            return nil
+        }
+        var group: Group?
+        Database.shared.database?.inTransaction({ fmdb, rollback in
+            if let cursor = Database.shared.getRecords(fmdb: fmdb, query: "select group_id, f_name, image_id, quote, created_by, created_date, parent, group_type, is_open, official from GROUPZ where group_id = '\(group_id)'"), cursor.next() {
+                group = Group(id: cursor.string(forColumnIndex: 0) ?? "",
+                              name: cursor.string(forColumnIndex: 1) ?? "",
+                              profile: cursor.string(forColumnIndex: 2) ?? "",
+                              quote: cursor.string(forColumnIndex: 3) ?? "",
+                              by: cursor.string(forColumnIndex: 4) ?? "",
+                              date: cursor.string(forColumnIndex: 5) ?? "",
+                              parent: cursor.string(forColumnIndex: 6) ?? "",
+                              groupType: cursor.string(forColumnIndex: 7) ?? "",
+                              isOpen: cursor.string(forColumnIndex: 8) ?? "",
+                              official: cursor.string(forColumnIndex: 9) ?? "")
+                cursor.close()
+            }
+        })
+        return group
+    }
     
 }
 
@@ -82,6 +103,22 @@ public class Topic: Model {
         return ""
     }
     
+    public static func getData(topic_id: String?) -> Topic? {
+        guard let topic_id = topic_id else {
+            return nil
+        }
+        var topic: Topic?
+        Database.shared.database?.inTransaction({ fmdb, rollback in
+            if let cursor = Database.shared.getRecords(fmdb: fmdb, query: "select chat_id, title, thumb from DISCUSSION_FORUM where chat_id = '\(topic_id)'"), cursor.next() {
+                topic = Topic(chatId: cursor.string(forColumnIndex: 0) ?? "",
+                              title: cursor.string(forColumnIndex: 1) ?? "",
+                              thumb: cursor.string(forColumnIndex: 2) ?? "")
+                cursor.close()
+            }
+        })
+        return topic
+    }
+    
 }
 
 public class Member: User {

+ 4 - 4
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorPersonal.swift

@@ -46,11 +46,11 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
     var stickers = [String]()
     public var unique_l_pin = ""
     public var isContactCenter = false
-    var isRequestContactCenter = true
+    public var isRequestContactCenter = true
     public var fromNotification = false
-    var onGoingCC = false
-    var fPinContacCenter = ""
-    var complaintId = ""
+    public var onGoingCC = false
+    public var fPinContacCenter = ""
+    public var complaintId = ""
     var channelContactCenter = ""
     var counter = 0
     var dateStartCC = ""