Browse Source

Defined FCM PushNotification Parameter (destination)

pull/1/head
InKwon James Kim 5 years ago
parent
commit
89b95e3bdf
  1. 4
      GME Remit.xcodeproj/project.pbxproj
  2. 2
      GME Remit.xcodeproj/xcshareddata/xcschemes/GME Remit.xcscheme
  3. 72
      GME Remit/AppDelegate.swift
  4. 21
      GME Remit/Models/Response/PushNotificationParam.swift
  5. BIN
      GME Remit/Supported Files/Assets.xcassets/.DS_Store

4
GME Remit.xcodeproj/project.pbxproj

@ -307,6 +307,7 @@
7366BECE235D331B00A8AE7C /* PriceModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7366BECD235D331B00A8AE7C /* PriceModel.swift */; };
7366BED0235D33A600A8AE7C /* CountryPriceModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7366BECF235D33A600A8AE7C /* CountryPriceModel.swift */; };
7366BED2235D343100A8AE7C /* CardInformation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7366BED1235D343100A8AE7C /* CardInformation.swift */; };
7367FF5E237401860005F644 /* PushNotificationParam.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7367FF5D237401860005F644 /* PushNotificationParam.swift */; };
736A8C402277EB2A00337A50 /* BiometricNotificationModuleInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 736A8C2D2277EB2900337A50 /* BiometricNotificationModuleInterface.swift */; };
736A8C412277EB2A00337A50 /* BiometricNotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 736A8C312277EB2900337A50 /* BiometricNotificationService.swift */; };
736A8C422277EB2A00337A50 /* BiometricNotificationServiceType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 736A8C322277EB2900337A50 /* BiometricNotificationServiceType.swift */; };
@ -2596,6 +2597,7 @@
7366BECD235D331B00A8AE7C /* PriceModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PriceModel.swift; sourceTree = "<group>"; };
7366BECF235D33A600A8AE7C /* CountryPriceModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountryPriceModel.swift; sourceTree = "<group>"; };
7366BED1235D343100A8AE7C /* CardInformation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardInformation.swift; sourceTree = "<group>"; };
7367FF5D237401860005F644 /* PushNotificationParam.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PushNotificationParam.swift; sourceTree = "<group>"; };
736A8C2D2277EB2900337A50 /* BiometricNotificationModuleInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BiometricNotificationModuleInterface.swift; sourceTree = "<group>"; };
736A8C312277EB2900337A50 /* BiometricNotificationService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BiometricNotificationService.swift; sourceTree = "<group>"; };
736A8C322277EB2900337A50 /* BiometricNotificationServiceType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BiometricNotificationServiceType.swift; sourceTree = "<group>"; };
@ -6854,6 +6856,7 @@
7318532B230EACA300BA9AE3 /* SendMoneyCountryViewModel.swift */,
7318532C230EACA300BA9AE3 /* SendMoneyDistrictViewModel.swift */,
7318532D230EACA300BA9AE3 /* SendMoneyProvinceViewModel.swift */,
7367FF5D237401860005F644 /* PushNotificationParam.swift */,
);
path = Response;
sourceTree = "<group>";
@ -14528,6 +14531,7 @@
73210DA222FBE73100715D6C /* RecipientsService.swift in Sources */,
D96A4FDC21460B4A00CFD507 /* SplashScreenViewInterface.swift in Sources */,
D950BED721549242008367A1 /* HomeWireframeInput.swift in Sources */,
7367FF5E237401860005F644 /* PushNotificationParam.swift in Sources */,
D977859D215DC55F00754079 /* TransactionHistoryModuleInterface.swift in Sources */,
73B4C8C022A5F2440078D495 /* SelectCouponInteractor.swift in Sources */,
7389600C22C2F208003FEA90 /* TablePresenterService.swift in Sources */,

2
GME Remit.xcodeproj/xcshareddata/xcschemes/GME Remit.xcscheme

@ -63,7 +63,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "1"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"

72
GME Remit/AppDelegate.swift

@ -74,17 +74,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
// Move push notification's destination
if let userInfo = launchOptions?[.remoteNotification] as? [String: AnyObject],
let aps = userInfo["aps"] as? [String: AnyObject],
let destination = aps["destination"] as? String,
let destinationType = PushNotificationDestination(rawValue: destination) {
print(destinationType)
self.window?.rootViewController = LauncherScreenWireframe().getMainView(destination: destinationType)
} else {
self.window?.rootViewController = LauncherScreenWireframe().getMainView()
}
let useInfo = launchOptions?[.remoteNotification] as? [String: AnyObject]
let destinationType = extractDestination(userInfo: useInfo)
self.window?.rootViewController = LauncherScreenWireframe().getMainView(destination: destinationType)
ChannelIO.initialize()
@ -95,6 +87,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
StoreReviewHelper.shared.incrementAppOpenedCount()
// XCODE 11.2 BUG
UITextViewWorkaround.executeWorkaround()
return true
}
@ -180,7 +173,9 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
) {
let userInfo = notification.request.content.userInfo
print("Message ID: \(userInfo["gcm_message_id"] ?? "nil")")
print(userInfo)
completionHandler([
UNNotificationPresentationOptions.alert,
@ -201,34 +196,41 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
ChannelIO.handlePushNotification(userInfo)
}
print(userInfo)
completionHandler()
// open push notification's destination
if let aps = userInfo["aps"] as? [String: AnyObject] {
guard let destination = aps["destination"] as? String else { return }
print(destination)
if window?.rootViewController is LGSideMenuController {
let baseVC = window?.rootViewController?.presentedViewController ?? window?.rootViewController
guard
window?.rootViewController is LGSideMenuController,
let destination = extractDestination(userInfo: userInfo as? [String: AnyObject]) else { return }
let baseVC = window?.rootViewController?.presentedViewController ?? window?.rootViewController
DispatchQueue.main.async {
switch destination {
case .trasactionHistory:
let vc = TransactionHistoryGroupWireframe().getMainView()
let naviVC = UINavigationController(rootViewController: vc)
baseVC?.present(naviVC, animated: true)
DispatchQueue.main.async {
switch destination {
case "TransactionHistory":
let vc = TransactionHistoryGroupWireframe().getMainView()
let naviVC = UINavigationController(rootViewController: vc)
baseVC?.present(naviVC, animated: true)
case "RechargeHistory":
let vc = RechargeHistoryWireframe().getMainView()
let naviVC = UINavigationController(rootViewController: vc)
baseVC?.present(naviVC, animated: true)
default: ()
}
}
case .rechargeHistory:
let vc = RechargeHistoryWireframe().getMainView()
let naviVC = UINavigationController(rootViewController: vc)
baseVC?.present(naviVC, animated: true)
}
}
completionHandler()
}
}
extension AppDelegate {
private func extractDestination(userInfo: [String : AnyObject]?) -> PushNotificationDestination? {
guard
let param = userInfo?["gcm.notification.param"] as? String,
let destination = PushNotificationParam(JSONString: param)?.destination,
let destinationType = PushNotificationDestination(rawValue: destination) else {
return nil
}
return destinationType
}
}

21
GME Remit/Models/Response/PushNotificationParam.swift

@ -0,0 +1,21 @@
//
// Destination.swift
// GME Remit
//
// Created by InKwon James Kim on 2019/11/07.
// Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
//
import ObjectMapper
struct PushNotificationParam: Mappable {
var destination: String?
init?(map: Map) {
}
mutating func mapping(map: Map) {
destination <- map["destination"]
}
}

BIN
GME Remit/Supported Files/Assets.xcassets/.DS_Store

Loading…
Cancel
Save