Commit 31972f3c authored by Steven杜宇's avatar Steven杜宇

// 出行推送

parent 1334471c
...@@ -6,14 +6,12 @@ ...@@ -6,14 +6,12 @@
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved. // Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
// //
import UIKit
import AuthenticationServices import AuthenticationServices
import UIKit
extension AppDelegate: JPUSHRegisterDelegate { extension AppDelegate: JPUSHRegisterDelegate {
// 注册JPush服务 // 注册JPush服务
func registerJPushService(_ launchOptions: [UIApplication.LaunchOptionsKey: Any]?) { func registerJPushService(_ launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
let entity: JPUSHRegisterEntity = JPUSHRegisterEntity() let entity: JPUSHRegisterEntity = JPUSHRegisterEntity()
entity.types = Int(JPAuthorizationOptions.alert.rawValue | entity.types = Int(JPAuthorizationOptions.alert.rawValue |
JPAuthorizationOptions.badge.rawValue | JPAuthorizationOptions.badge.rawValue |
...@@ -30,13 +28,13 @@ extension AppDelegate: JPUSHRegisterDelegate { ...@@ -30,13 +28,13 @@ extension AppDelegate: JPUSHRegisterDelegate {
// apsForProduction:isProduction // apsForProduction:isProduction
// advertisingIdentifier:advertisingId]; // advertisingIdentifier:advertisingId];
#if DEBUG #if DEBUG
let isProduction = false let isProduction = false
#elseif TESTENV #elseif TESTENV
let isProduction = false let isProduction = false
#else #else
let isProduction = true let isProduction = true
#endif #endif
JPUSHService.setup(withOption: launchOptions, JPUSHService.setup(withOption: launchOptions,
appKey: YhConstant.Jpush.appKey, appKey: YhConstant.Jpush.appKey,
channel: "appStore", channel: "appStore",
...@@ -45,23 +43,23 @@ extension AppDelegate: JPUSHRegisterDelegate { ...@@ -45,23 +43,23 @@ extension AppDelegate: JPUSHRegisterDelegate {
// 系统获取Token // 系统获取Token
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let deviceTokenStr = deviceToken.map {String(format: "%02.2hhx", arguments: [$0]) }.joined() let deviceTokenStr = deviceToken.map { String(format: "%02.2hhx", arguments: [$0]) }.joined()
print("deviceToken:\(deviceTokenStr)") print("deviceToken:\(deviceTokenStr)")
JPUSHService.registerDeviceToken(deviceToken) JPUSHService.registerDeviceToken(deviceToken)
YHLoginManager.shared.deviceTokenModel.deviceToken = deviceTokenStr YHLoginManager.shared.deviceTokenModel.deviceToken = deviceTokenStr
YHButlerServiceManager.shared.updateApnsToken(token: deviceToken) YHButlerServiceManager.shared.updateApnsToken(token: deviceToken)
} }
// 获取token 失败 // 获取token 失败
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { // 可选 func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { // 可选
print("did Fail To Register For Remote Notifications With Error: \(error)") print("did Fail To Register For Remote Notifications With Error: \(error)")
#if DEBUG #if DEBUG
YHHUD.flash(message: error.localizedDescription) YHHUD.flash(message: error.localizedDescription)
#elseif TESTENV #elseif TESTENV
YHHUD.flash(message: error.localizedDescription) YHHUD.flash(message: error.localizedDescription)
#else #else
#endif #endif
} }
// 点推送进来执行这个方法 // 点推送进来执行这个方法
...@@ -74,7 +72,6 @@ extension AppDelegate: JPUSHRegisterDelegate { ...@@ -74,7 +72,6 @@ extension AppDelegate: JPUSHRegisterDelegate {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25, execute: { DispatchQueue.main.asyncAfter(deadline: .now() + 0.25, execute: {
goToMessagePage() goToMessagePage()
}) })
} }
// 后台进前台 // 后台进前台
...@@ -87,8 +84,7 @@ extension AppDelegate: JPUSHRegisterDelegate { ...@@ -87,8 +84,7 @@ extension AppDelegate: JPUSHRegisterDelegate {
YHOSSManager.share.getOSSID() YHOSSManager.share.getOSSID()
} }
func jpushNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: ((Int) -> Void)) { func jpushNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: (Int) -> Void) {
let userInfo = notification.request.content.userInfo let userInfo = notification.request.content.userInfo
if notification.request.trigger is UNPushNotificationTrigger { if notification.request.trigger is UNPushNotificationTrigger {
JPUSHService.handleRemoteNotification(userInfo) JPUSHService.handleRemoteNotification(userInfo)
...@@ -106,7 +102,7 @@ extension AppDelegate: JPUSHRegisterDelegate { ...@@ -106,7 +102,7 @@ extension AppDelegate: JPUSHRegisterDelegate {
} }
} }
func jpushNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: (() -> Void)) { func jpushNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void) {
let userInfo = response.notification.request.content.userInfo let userInfo = response.notification.request.content.userInfo
if response.notification.request.trigger is UNPushNotificationTrigger { if response.notification.request.trigger is UNPushNotificationTrigger {
JPUSHService.handleRemoteNotification(userInfo) JPUSHService.handleRemoteNotification(userInfo)
...@@ -118,7 +114,8 @@ extension AppDelegate: JPUSHRegisterDelegate { ...@@ -118,7 +114,8 @@ extension AppDelegate: JPUSHRegisterDelegate {
YHLoginManager.shared.needJumpToMsgTabFlag = true YHLoginManager.shared.needJumpToMsgTabFlag = true
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25, execute: { DispatchQueue.main.asyncAfter(deadline: .now() + 0.25, execute: {
goToMessagePage() goToMessagePage()
if let msgType = userInfo["msg_type"] as? Int, msgType == YHMessageType.article.rawValue { if let msgType = userInfo["msg_type"] as? Int {
if msgType == YHMessageType.article.rawValue {
let model = YHNewsModel() let model = YHNewsModel()
let taskId = userInfo["task_id"] as? Int ?? 0 let taskId = userInfo["task_id"] as? Int ?? 0
model.article_id = userInfo["article_id"] as? Int ?? 0 model.article_id = userInfo["article_id"] as? Int ?? 0
...@@ -130,25 +127,29 @@ extension AppDelegate: JPUSHRegisterDelegate { ...@@ -130,25 +127,29 @@ extension AppDelegate: JPUSHRegisterDelegate {
printLog("DDDDY: \(model.id)") printLog("DDDDY: \(model.id)")
yh_newsList.enterDetail(model) yh_newsList.enterDetail(model)
self.viewModel.readMessage(taskId: taskId) { _, _ in self.viewModel.readMessage(taskId: taskId) { _, _ in
}
return
}
if msgType == YHMessageType.trip.rawValue {
if let url = userInfo["url"] as? String {
YHMessageDetailListVC.detailWithTripUrl(url)
}
return
} }
} }
}) })
} }
func jpushNotificationCenter(_ center: UNUserNotificationCenter, openSettingsFor notification: UNNotification) { func jpushNotificationCenter(_ center: UNUserNotificationCenter, openSettingsFor notification: UNNotification) {
} }
func jpushNotificationAuthorization(_ status: JPAuthorizationStatus, withInfo info: [AnyHashable: Any]?) { func jpushNotificationAuthorization(_ status: JPAuthorizationStatus, withInfo info: [AnyHashable: Any]?) {
} }
} }
extension AppDelegate { extension AppDelegate {
func handleAppleLoginUser() { func handleAppleLoginUser() {
if #available(iOS 13.0, *) { if #available(iOS 13.0, *) {
// 注意 存储用户标识信息需要使用钥匙串来存储 这里使用NSUserDefaults 做的简单示例 // 注意 存储用户标识信息需要使用钥匙串来存储 这里使用NSUserDefaults 做的简单示例
let userIdentifier = UserDefaults.standard.value(forKey: "appleID") as? String let userIdentifier = UserDefaults.standard.value(forKey: "appleID") as? String
......
...@@ -52,6 +52,9 @@ class YHOrderTipsItemView: UIView { ...@@ -52,6 +52,9 @@ class YHOrderTipsItemView: UIView {
} else if msg.type == YHMessageType.article.rawValue { } else if msg.type == YHMessageType.article.rawValue {
return "银河资讯" return "银河资讯"
} else if msg.type == YHMessageType.trip.rawValue {
return "礼品兑换提醒"
} else { } else {
return "--" return "--"
} }
......
...@@ -286,6 +286,19 @@ class YHMessageDetailListVC: YHBaseViewController { ...@@ -286,6 +286,19 @@ class YHMessageDetailListVC: YHBaseViewController {
} }
} }
} }
static func detailWithTripUrl(_ itemUrl: String) {
if !itemUrl.isEmpty, let token = YHLoginManager.shared.userModel?.token, token.count > 5 {
var url = itemUrl + "&param=\(YHLoginManager.shared.h5Token)"
url = url + "&app_platform=ios" + "&app_version=" + UIDevice.appVersion()
printLog("UURL: \(url)")
let vc = YHH5WebViewVC()
vc.url = url
vc.isFullScreenFlag = true
vc.isNeedRefreshDataFlag = true
UIViewController.current?.navigationController?.pushViewController(vc)
}
}
} }
extension YHMessageDetailListVC: UITableViewDelegate, UITableViewDataSource { extension YHMessageDetailListVC: UITableViewDelegate, UITableViewDataSource {
...@@ -329,24 +342,37 @@ extension YHMessageDetailListVC: UITableViewDelegate, UITableViewDataSource { ...@@ -329,24 +342,37 @@ extension YHMessageDetailListVC: UITableViewDelegate, UITableViewDataSource {
return return
} }
if self.type == YHMessageType.trip.rawValue {
Self.detailWithTripUrl(item.url)
return
}
printLog("redirectPage:\(item.redirectPage)") printLog("redirectPage:\(item.redirectPage)")
if item.redirectPage == YHRedirectPage.serviceTab.rawValue { // 服务tab页 if item.redirectPage == YHRedirectPage.serviceTab.rawValue { // 服务tab页
UIViewController.current?.navigationController?.popToRootViewController(animated: false) UIViewController.current?.navigationController?.popToRootViewController(animated: false)
goTabBarBy(tabType: .service) goTabBarBy(tabType: .service)
return
}
} else if item.redirectPage == YHRedirectPage.lifeTab.rawValue { // 首页-生活tab if item.redirectPage == YHRedirectPage.lifeTab.rawValue { // 首页-生活tab
UIViewController.current?.navigationController?.popToRootViewController(animated: false) UIViewController.current?.navigationController?.popToRootViewController(animated: false)
goTabBarBy(tabType: .home) goTabBarBy(tabType: .home)
NotificationCenter.default.post(name: YhConstant.YhNotification.didJumpToHomePageLifeTabNotification, object: nil) NotificationCenter.default.post(name: YhConstant.YhNotification.didJumpToHomePageLifeTabNotification, object: nil)
return
} else if item.redirectPage == YHRedirectPage.newsTab.rawValue { // 首页-资讯tab }
if item.redirectPage == YHRedirectPage.newsTab.rawValue { // 首页-资讯tab
UIViewController.current?.navigationController?.popToRootViewController(animated: false) UIViewController.current?.navigationController?.popToRootViewController(animated: false)
goTabBarBy(tabType: .home) goTabBarBy(tabType: .home)
NotificationCenter.default.post(name: YhConstant.YhNotification.didJumpToHomePageNewsTabNotification, object: nil) NotificationCenter.default.post(name: YhConstant.YhNotification.didJumpToHomePageNewsTabNotification, object: nil)
return
} else { }
// 处理订单相关逻辑
if let orderId = Int(item.orderId) { if let orderId = Int(item.orderId) {
printLog("orderId: \(orderId)") printLog("orderId: \(orderId)")
self.requestOrderStatus(orderId: orderId) { self.requestOrderStatus(orderId: orderId) {
...@@ -361,7 +387,6 @@ extension YHMessageDetailListVC: UITableViewDelegate, UITableViewDataSource { ...@@ -361,7 +387,6 @@ extension YHMessageDetailListVC: UITableViewDelegate, UITableViewDataSource {
} }
} }
} }
}
private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat { private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat {
return 1.0 return 1.0
......
...@@ -269,7 +269,9 @@ class YHMessageListVC: YHBaseViewController { ...@@ -269,7 +269,9 @@ class YHMessageListVC: YHBaseViewController {
} }
} }
emptyDataTipsView.isHidden = msgArr.count > 0 // 礼品兑换通知
self.msgArr.append(self.viewModel.msgList.trip)
self.emptyDataTipsView.isHidden = self.msgArr.count > 0
self.tableView.reloadData() self.tableView.reloadData()
didRefreshYinHeManagerUnreadMsg() didRefreshYinHeManagerUnreadMsg()
} }
......
...@@ -21,6 +21,7 @@ enum YHMessageType: Int { ...@@ -21,6 +21,7 @@ enum YHMessageType: Int {
case renewal = 8 // 身份续签 case renewal = 8 // 身份续签
case business = 9 // 商务 case business = 9 // 商务
case article = 10 // 资讯 case article = 10 // 资讯
case trip = 11 // 礼物
case yinheManager = 9527 // 银河管家 case yinheManager = 9527 // 银河管家
} }
...@@ -77,6 +78,9 @@ class YHMessageInfoModel: SmartCodable { ...@@ -77,6 +78,9 @@ class YHMessageInfoModel: SmartCodable {
} else if type == YHMessageType.article.rawValue { } else if type == YHMessageType.article.rawValue {
return "银河资讯" return "银河资讯"
} else if type == YHMessageType.trip.rawValue {
return "礼品兑换提醒"
} }
return "" return ""
} }
...@@ -93,6 +97,7 @@ class YHMsgListModel: SmartCodable { ...@@ -93,6 +97,7 @@ class YHMsgListModel: SmartCodable {
var renewal: YHMessageInfoModel = YHMessageInfoModel() var renewal: YHMessageInfoModel = YHMessageInfoModel()
var business: YHMessageInfoModel = YHMessageInfoModel() var business: YHMessageInfoModel = YHMessageInfoModel()
var article: YHMessageInfoModel = YHMessageInfoModel() var article: YHMessageInfoModel = YHMessageInfoModel()
var trip: YHMessageInfoModel = YHMessageInfoModel()
required init() { required init() {
self.information.type = YHMessageType.infoFill.rawValue self.information.type = YHMessageType.infoFill.rawValue
...@@ -105,10 +110,11 @@ class YHMsgListModel: SmartCodable { ...@@ -105,10 +110,11 @@ class YHMsgListModel: SmartCodable {
self.renewal.type = YHMessageType.renewal.rawValue self.renewal.type = YHMessageType.renewal.rawValue
self.business.type = YHMessageType.business.rawValue self.business.type = YHMessageType.business.rawValue
self.article.type = YHMessageType.article.rawValue self.article.type = YHMessageType.article.rawValue
self.trip.type = YHMessageType.trip.rawValue
} }
enum CodingKeys: String, CodingKey { enum CodingKeys: String, CodingKey {
case information, certificate, draft, signature, approval, renewal, business, article case information, certificate, draft, signature, approval, renewal, business, article, trip
case dataSubmission = "data_submission" case dataSubmission = "data_submission"
case goToHK = "go_to_hk" case goToHK = "go_to_hk"
} }
......
...@@ -70,6 +70,10 @@ class YHDetailMessageCell: UITableViewCell { ...@@ -70,6 +70,10 @@ class YHDetailMessageCell: UITableViewCell {
} else if type == YHMessageType.business.rawValue { } else if type == YHMessageType.business.rawValue {
bottomBtn.setTitle("".local, for: .normal) bottomBtn.setTitle("".local, for: .normal)
lineView.isHidden = true lineView.isHidden = true
} else if type == YHMessageType.trip.rawValue {
bottomBtn.setTitle("去查看".local, for: .normal)
} }
var bottomBtnHeight = (type == YHMessageType.business.rawValue) ? 0.0 : 52.0 var bottomBtnHeight = (type == YHMessageType.business.rawValue) ? 0.0 : 52.0
......
...@@ -69,6 +69,9 @@ class YHMessageSessionCell: UITableViewCell { ...@@ -69,6 +69,9 @@ class YHMessageSessionCell: UITableViewCell {
self.iconImgView.image = UIImage(named: "msg_icon_news") self.iconImgView.image = UIImage(named: "msg_icon_news")
self.iconContentView.backgroundColor = UIColor(hex: 0xF0F5FF) self.iconContentView.backgroundColor = UIColor(hex: 0xF0F5FF)
} else if model.type == YHMessageType.trip.rawValue {
self.iconImgView.image = UIImage(named: "msg_icon_gift")
} }
self.badgeLabel.isHidden = model.unreadCount <= 0 self.badgeLabel.isHidden = model.unreadCount <= 0
......
...@@ -45,6 +45,7 @@ class YHMsgViewModel: NSObject { ...@@ -45,6 +45,7 @@ class YHMsgViewModel: NSObject {
self.msgList.renewal.type = YHMessageType.renewal.rawValue self.msgList.renewal.type = YHMessageType.renewal.rawValue
self.msgList.business.type = YHMessageType.business.rawValue self.msgList.business.type = YHMessageType.business.rawValue
self.msgList.article.type = YHMessageType.article.rawValue self.msgList.article.type = YHMessageType.article.rawValue
self.msgList.trip.type = YHMessageType.trip.rawValue
callBackBlock(true, nil) callBackBlock(true, nil)
} else { } else {
let error: YHErrorModel = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg) let error: YHErrorModel = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg)
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Frame@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Frame@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment