Notifly 설정 추가
This commit is contained in:
		| @@ -1,5 +1,5 @@ | ||||
| { | ||||
|   "originHash" : "e2b266c250e8dfef68a5b39f94cb7106349e1dc72b7b5f653706ce88e5d8bba3", | ||||
|   "originHash" : "a28a1cfc016af3a4b862bc113cbf664d4af66d915c851ea4b7992f9bbe49ab27", | ||||
|   "pins" : [ | ||||
|     { | ||||
|       "identity" : "abseil-cpp-binary", | ||||
| @@ -163,6 +163,15 @@ | ||||
|         "version" : "2.30909.0" | ||||
|       } | ||||
|     }, | ||||
|     { | ||||
|       "identity" : "notifly-ios-sdk", | ||||
|       "kind" : "remoteSourceControl", | ||||
|       "location" : "https://github.com/team-michael/notifly-ios-sdk", | ||||
|       "state" : { | ||||
|         "revision" : "e3a0a4669c4f8c8c48d811d1831e803447612ec2", | ||||
|         "version" : "1.16.0" | ||||
|       } | ||||
|     }, | ||||
|     { | ||||
|       "identity" : "popupview", | ||||
|       "kind" : "remoteSourceControl", | ||||
|   | ||||
| @@ -7,6 +7,7 @@ | ||||
|  | ||||
| import UIKit | ||||
|  | ||||
| import notifly_sdk | ||||
| import AppsFlyerLib | ||||
| import FBSDKCoreKit | ||||
| import FirebaseCore | ||||
| @@ -19,6 +20,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | ||||
|      | ||||
|     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { | ||||
|         FirebaseApp.configure() | ||||
|         Notifly.initialize(projectId: NOTIFLY_PROJECT_ID, username: NOTIFLY_USERNAME, password: NOTIFLY_PASSWORD) | ||||
|         Messaging.messaging().delegate = self | ||||
|          | ||||
|         // For iOS 10 display notification (sent via APNS) | ||||
| @@ -56,9 +58,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | ||||
|     func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { | ||||
|         UserDefaults.set(deviceToken, forKey: .devicePushToken) | ||||
|         Messaging.messaging().apnsToken = deviceToken | ||||
|         Notifly.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken) | ||||
|     } | ||||
|      | ||||
|     func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { | ||||
|         Notifly.application(application, didFailToRegisterForRemoteNotificationsWithError: error) | ||||
|     } | ||||
|      | ||||
|     func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([any UIUserActivityRestoring]?) -> Void) -> Bool { | ||||
| @@ -164,6 +168,8 @@ extension AppDelegate : UNUserNotificationCenterDelegate { | ||||
|         // With swizzling disabled you must let Messaging know about the message, for Analytics | ||||
|         Messaging.messaging().appDidReceiveMessage(userInfo) | ||||
|          | ||||
|         Notifly.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler) | ||||
|          | ||||
|         // ... | ||||
|          | ||||
|         // Print full message. | ||||
| @@ -180,6 +186,7 @@ extension AppDelegate : UNUserNotificationCenterDelegate { | ||||
|          | ||||
|         // With swizzling disabled you must let Messaging know about the message, for Analytics | ||||
|         Messaging.messaging().appDidReceiveMessage(userInfo) | ||||
|         Notifly.userNotificationCenter(center, didReceive: response) | ||||
|          | ||||
|         let roomIdString = userInfo["room_id"] as? String | ||||
|         let contentIdString = userInfo["content_id"] as? String | ||||
|   | ||||
| @@ -51,4 +51,59 @@ final class AppViewModel: ObservableObject { | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     func getMemberInfo() { | ||||
|         if !UserDefaults.string(forKey: UserDefaultsKey.token).trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { | ||||
|             userRepository.getMemberInfo() | ||||
|                 .sink { result in | ||||
|                     switch result { | ||||
|                     case .finished: | ||||
|                         DEBUG_LOG("finish") | ||||
|                     case .failure(let error): | ||||
|                         ERROR_LOG(error.localizedDescription) | ||||
|                     } | ||||
|                 } receiveValue: { response in | ||||
|                     let responseData = response.data | ||||
|                      | ||||
|                     do { | ||||
|                         let jsonDecoder = JSONDecoder() | ||||
|                         let decoded = try jsonDecoder.decode(ApiResponse<GetMemberInfoResponse>.self, from: responseData) | ||||
|                          | ||||
|                         if let data = decoded.data, decoded.success { | ||||
|                             UserDefaults.set(data.can, forKey: .can) | ||||
|                             UserDefaults.set(data.isAuth, forKey: .auth) | ||||
|                             UserDefaults.set(data.role.rawValue, forKey: .role) | ||||
|                             UserDefaults.set(data.auditionNotice ?? false, forKey: .isAuditionNotification) | ||||
|                             if data.followingChannelLiveNotice == nil && data.followingChannelUploadContentNotice == nil && data.messageNotice == nil { | ||||
|                                 AppState.shared.isShowNotificationSettingsDialog = true | ||||
|                             } | ||||
|                              | ||||
|                             let dateFormatter = DateFormatter() | ||||
|                             dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss" | ||||
|                              | ||||
|                             let currentDate = Date() | ||||
|                             let lastActiveDate = dateFormatter.string(from: currentDate) | ||||
|                              | ||||
|                             var params = [ | ||||
|                                 "nickname": UserDefaults.string(forKey: .nickname), | ||||
|                                 "last_active_date": lastActiveDate, | ||||
|                                 "charge_count": data.chargeCount, | ||||
|                                 "signup_date": data.signupDate, | ||||
|                                 "is_auth": data.isAuth, | ||||
|                                 "can": data.can | ||||
|                             ] | ||||
|                              | ||||
|                             if data.isAuth { | ||||
|                                 params["gender"] = data.gender | ||||
|                             } | ||||
|                              | ||||
|                             NotiflyClient.shared.setUser(userId: UserDefaults.int(forKey: .userId), params: params) | ||||
|                         } | ||||
|                     } catch { | ||||
|                         print(error) | ||||
|                     } | ||||
|                 } | ||||
|                 .store(in: &subscription) | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -28,6 +28,7 @@ struct SodaLiveApp: App { | ||||
|                      | ||||
|                     AppsFlyerLib.shared().start() | ||||
|                     viewModel.fetchAndUpdateIdfa() | ||||
|                     viewModel.getMemberInfo() | ||||
|                 } | ||||
|                 .onOpenURL { url in | ||||
|                     DEBUG_LOG("I have received a URL through a custom scheme! \(url.absoluteString)") | ||||
|   | ||||
| @@ -15,3 +15,7 @@ let AGORA_APP_CERTIFICATE = "ae18ade3afcf4086bd4397726eb0654c" | ||||
|  | ||||
| let BOOTPAY_APP_ID = "6242a7772701800023f68b2f" | ||||
| let BOOTPAY_APP_HECTO_ID = "667fca5d3bab7404f831c3e5" | ||||
|  | ||||
| let NOTIFLY_PROJECT_ID = "5f7ebe90d1ce5f0392164b8a53a662bc" | ||||
| let NOTIFLY_USERNAME = "voiceon" | ||||
| let NOTIFLY_PASSWORD = "c6c585db0aaa4189be44d0467c7d66b6@A" | ||||
|   | ||||
| @@ -74,6 +74,27 @@ final class HomeViewModel: ObservableObject { | ||||
|                         if data.followingChannelLiveNotice == nil && data.followingChannelUploadContentNotice == nil && data.messageNotice == nil { | ||||
|                             AppState.shared.isShowNotificationSettingsDialog = true | ||||
|                         } | ||||
|  | ||||
|                         let dateFormatter = DateFormatter() | ||||
|                         dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss" | ||||
|                          | ||||
|                         let currentDate = Date() | ||||
|                         let lastActiveDate = dateFormatter.string(from: currentDate) | ||||
|                          | ||||
|                         var params = [ | ||||
|                             "nickname": UserDefaults.string(forKey: .nickname), | ||||
|                             "last_active_date": lastActiveDate, | ||||
|                             "charge_count": data.chargeCount, | ||||
|                             "signup_date": data.signupDate, | ||||
|                             "is_auth": data.isAuth, | ||||
|                             "can": data.can | ||||
|                         ] | ||||
|                          | ||||
|                         if data.isAuth { | ||||
|                             params["gender"] = data.gender | ||||
|                         } | ||||
|                          | ||||
|                         NotiflyClient.shared.setUser(userId: UserDefaults.int(forKey: .userId), params: params) | ||||
|                     } | ||||
|                 } catch { | ||||
|                     print(error) | ||||
|   | ||||
| @@ -14,6 +14,9 @@ enum MemberRole: String, Decodable { | ||||
| struct GetMemberInfoResponse: Decodable { | ||||
|     let can: Int | ||||
|     let isAuth: Bool | ||||
|     let gender: String? | ||||
|     let signupDate: String | ||||
|     let chargeCount: Int | ||||
|     let role: MemberRole | ||||
|     let messageNotice: Bool? | ||||
|     let followingChannelLiveNotice: Bool? | ||||
|   | ||||
| @@ -36,6 +36,7 @@ final class SettingsViewModel: ObservableObject { | ||||
|                     let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData) | ||||
|                      | ||||
|                     if decoded.success { | ||||
|                         NotiflyClient.shared.logout() | ||||
|                         onSuccess() | ||||
|                     } else { | ||||
|                         if let message = decoded.message { | ||||
| @@ -75,6 +76,7 @@ final class SettingsViewModel: ObservableObject { | ||||
|                     let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData) | ||||
|                      | ||||
|                     if decoded.success { | ||||
|                         NotiflyClient.shared.logout() | ||||
|                         onSuccess() | ||||
|                     } else { | ||||
|                         if let message = decoded.message { | ||||
|   | ||||
							
								
								
									
										21
									
								
								SodaLive/Sources/Tracking/NotiflyClient.swift
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								SodaLive/Sources/Tracking/NotiflyClient.swift
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| // | ||||
| //  NotiflyClient.swift | ||||
| //  SodaLive | ||||
| // | ||||
| //  Created by klaus on 3/12/25. | ||||
| // | ||||
|  | ||||
| import notifly_sdk | ||||
|  | ||||
| class NotiflyClient { | ||||
|     static let shared = NotiflyClient() | ||||
|      | ||||
|     func setUser(userId: Int, params: [String : Any]) { | ||||
|         Notifly.setUserId(userId: "voiceon_user\(userId)") | ||||
|         Notifly.setUserProperties(userProperties: params) | ||||
|     } | ||||
|      | ||||
|     func logout() { | ||||
|         Notifly.setUserId(userId: nil) | ||||
|     } | ||||
| } | ||||
| @@ -15,3 +15,7 @@ let AGORA_APP_CERTIFICATE = "15cadeea4ba94ff7b091c9a10f4bf4a6" | ||||
|  | ||||
| let BOOTPAY_APP_ID = "64c35be1d25985001dc50c88" | ||||
| let BOOTPAY_APP_HECTO_ID = "664c1707b18b225deca4b42a" | ||||
|  | ||||
| let NOTIFLY_PROJECT_ID = "765102ec85855aa680da35f1b0f55712" | ||||
| let NOTIFLY_USERNAME = "voiceon" | ||||
| let NOTIFLY_PASSWORD = "c6c585db0aaa4189be44d0467c7d66b6@A" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Yu Sung
					Yu Sung