Pārlūkot izejas kodu

feat: 补充推送权限申请弹窗逻辑

陈文艺 1 mēnesi atpakaļ
vecāks
revīzija
8989b7b4f6

+ 1 - 0
Lanu.xcodeproj/project.pbxproj

@@ -53,6 +53,7 @@
 				"Common/Extension/UIButton+Theme.swift",
 				"Common/Extension/UIColor+Extension.swift",
 				"Common/Extension/UIImage+Extension.swift",
+				"Common/Extension/UIImageView+Extension.swift",
 				"Common/Extension/UIScrollView+Extension.swift",
 				"Common/Extension/UITableView+Extension.swift",
 				"Common/Extension/UIView+Extension.swift",

+ 23 - 0
Lanu/AppDelegate.swift

@@ -37,6 +37,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
             LNDeeplinkManager.shared.handleDeepLink(url)
         }
         reportLanguage()
+        requestNotificationPermissions()
         
         return true
     }
@@ -123,4 +124,26 @@ extension AppDelegate {
 //        config?.delegate = self
         Adjust.initSdk(config)
     }
+    
+    private func requestNotificationPermissions() {
+        let center = UNUserNotificationCenter.current()
+        
+        // 请求通知权限(可根据需求调整,如添加 sound/badge 等)
+        center.requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
+            if let error = error {
+                Log.e("请求推送权限失败: \(error.localizedDescription)")
+                return
+            }
+            
+            if granted {
+                Log.i("用户已授予推送权限")
+                // 权限获取成功后,注册远程推送
+                DispatchQueue.main.async {
+                    UIApplication.shared.registerForRemoteNotifications()
+                }
+            } else {
+                Log.i("用户拒绝了推送权限")
+            }
+        }
+    }
 }

+ 15 - 0
Lanu/Common/Extension/UIImageView+Extension.swift

@@ -0,0 +1,15 @@
+//
+//  UIImageView+Extension.swift
+//  Gami
+//
+//  Created by OneeChan on 2026/2/12.
+//
+
+import Foundation
+
+
+extension UIImageView {
+    func showAvatar(_ url: String?) {
+        sd_setImage(with: URL(string: url ?? ""), placeholderImage: .icProfileLoginAvatar)
+    }
+}

+ 7 - 1
Lanu/Manager/IM/LNIMManager.swift

@@ -306,8 +306,14 @@ extension LNIMManager {
                 TUICallEngine.createInstance().calls(userIdList: [uid], callMediaType: .audio, params: param) { [weak self] in
                     guard let self else { return }
                     bellPlayer.startPlay(isInCome: false)
-                } fail: { _, err in
+                } fail: { [weak panel, weak floatingView] _, err in
                     showToast(err)
+                    if let panel {
+                        panel.dismiss()
+                    }
+                    if let floatingView {
+                        floatingView.dismiss()
+                    }
                 }
             }
         }

+ 1 - 1
Lanu/Views/Game/MateList/LNGameMateListCell.swift

@@ -51,7 +51,7 @@ class LNGameMateListCell: UITableViewCell {
     }
     
     func update(_ item: LNGameMateListItemVO) {
-        avatar.sd_setImage(with: URL(string: item.avatar))
+        avatar.showAvatar(item.avatar)
         onlineView.isHidden = !item.online
         priceLabel.text = item.price.toDisplay
         unitLabel.text = "/\(item.unit)"

+ 1 - 1
Lanu/Views/Game/OrderCenter/Visitors/LNVisitorItemCell.swift

@@ -27,7 +27,7 @@ class LNVisitorItemCell: UITableViewCell {
     }
     
     func update(_ item: LNVisitorItemVO) {
-        avatar.sd_setImage(with: URL(string: item.avatar))
+        avatar.showAvatar(item.avatar)
         onlineView.isHidden = !item.online
         nameLabel.text = item.nickname
         

+ 1 - 1
Lanu/Views/Game/Skill/LNSkillCommentsView.swift

@@ -174,7 +174,7 @@ class LNSkillCommentItemView: UIView {
     }
     
     func update(_ comment: LNSkillCommentVO) {
-        avatar.sd_setImage(with: URL(string: comment.avatar))
+        avatar.showAvatar(comment.avatar)
         nameLabel.text = comment.nickname
         starView.score = comment.star
         commentLabel.text = comment.comment

+ 1 - 1
Lanu/Views/Game/Skill/LNSkillDetailViewController.swift

@@ -93,7 +93,7 @@ extension LNSkillDetailViewController {
             
             bottomMenu.update(info)
             
-            avatar.sd_setImage(with: URL(string: info.avatar))
+            avatar.showAvatar(info.avatar)
             titleLabel.text = info.nickname
             followButton.isHidden = info.follow || info.userNo.isMyUid
             moreButton.isHidden = info.userNo.isMyUid

+ 4 - 1
Lanu/Views/IM/Chat/GameMate/LNIMChatGameMateOrderView.swift

@@ -94,7 +94,8 @@ extension LNIMChatGameMateOrderView {
         let isCreator = order.buyerUserNo.isMyUid
         
         gameIc.sd_setImage(with: URL(string: order.categoryIcon))
-        descLabel.text = "\(order.bizCategoryName)/\(order.unit) x \(order.purchaseQty)"
+//        descLabel.text = "\(order.bizCategoryName)/\(order.unit) x \(order.purchaseQty)"
+        descLabel.text = "adsjkf a;lsjdf jasd; fja;dskj f;asdj f;ajsd f;ajsd f;ajk sdf;ajksd;fja;sdjfajds f;adfj"
         extraLabel.text = .init(key: "A00056", order.customerRemark)
         
         actionView.isHidden = true
@@ -291,6 +292,8 @@ extension LNIMChatGameMateOrderView {
         callButton.setBackgroundImage(.primary_8, for: .normal)
         callButton.layer.cornerRadius = 12
         callButton.clipsToBounds = true
+        callButton.setContentHuggingPriority(.required, for: .horizontal)
+        callButton.setContentCompressionResistancePriority(.required, for: .horizontal)
         callButton.snp.makeConstraints { make in
             make.height.equalTo(24)
         }

+ 1 - 1
Lanu/Views/IM/Chat/LNIMChatViewController.swift

@@ -114,7 +114,7 @@ extension LNIMChatViewController {
             guard let self else { return }
             guard let newInfo else { return }
             nameLabel.text = viewModel.remark?.isEmpty == false ? viewModel.remark : newInfo.nickname
-            avatar.sd_setImage(with: URL(string: newInfo.avatar))
+            avatar.showAvatar(newInfo.avatar)
         }.store(in: &bag)
         viewModel.$remark.sink { [weak self] newValue in
             guard let self else { return }

+ 1 - 1
Lanu/Views/IM/Chat/VoiceCall/LNAudioCallFloatingView.swift

@@ -49,7 +49,7 @@ class LNAudioCallFloatingView: UIView {
 }
 
 extension LNAudioCallFloatingView {
-    private func dismiss() {
+    func dismiss() {
         removeFromSuperview()
     }
     

+ 2 - 2
Lanu/Views/IM/Chat/VoiceCall/LNAudioCallPanel.swift

@@ -83,8 +83,8 @@ extension LNAudioCallPanel {
         LNProfileManager.shared.getUserProfile(uid: uid) { [weak self] info in
             guard let self else { return }
             guard let info else { return }
-            background.sd_setImage(with: URL(string: info.avatar))
-            avatar.sd_setImage(with: URL(string: info.avatar))
+            background.showAvatar(info.avatar)
+            avatar.showAvatar(info.avatar)
             nameLabel.text = info.nickname
         }
     }

+ 2 - 2
Lanu/Views/IM/ConversationList/LNIMConversationCell.swift

@@ -63,7 +63,7 @@ class LNIMConversationCell: UITableViewCell {
         curItem = item
         
         if let userInfo = item.extraInfo?.userInfo {
-            avatar.sd_setImage(with: URL(string: userInfo.avatar))
+            avatar.showAvatar(userInfo.avatar)
         } else if let userId = item.userID, !userId.isImOfficialId {
             LNProfileManager.shared.getUserProfile(uid: userId) { [weak self] info in
                 guard let self else { return }
@@ -72,7 +72,7 @@ class LNIMConversationCell: UITableViewCell {
                 
                 guard info.userNo == curItem?.userID else { return }
                 
-                avatar.sd_setImage(with: URL(string: info.avatar))
+                avatar.showAvatar(info.avatar)
                 titleLabel.text = item.displayName
             }
         }

+ 3 - 3
Lanu/Views/Order/Create/LNCreateOrderPanel.swift

@@ -66,7 +66,7 @@ class LNCreateOrderPanel: LNPopupView {
     
     func update(_ detail: LNGameMateSkillDetailVO, count: Int, extra: String) {
         gameNameLabel.text = detail.categoryName
-        avatar.sd_setImage(with: URL(string: detail.avatar))
+        avatar.showAvatar(detail.avatar)
         nameLabel.text = detail.nickname
         priceLabel.text = "\(detail.price.toDisplay)/\(detail.unit)"
         
@@ -79,7 +79,7 @@ class LNCreateOrderPanel: LNPopupView {
     
     func update(_ skill: LNGameMateSkillVO, user: LNUserProfileVO) {
         gameNameLabel.text = skill.name
-        avatar.sd_setImage(with: URL(string: user.avatar))
+        avatar.showAvatar(user.avatar)
         nameLabel.text = user.nickname
         priceLabel.text = "\(skill.price.toDisplay)/\(skill.unit)"
         
@@ -90,7 +90,7 @@ class LNCreateOrderPanel: LNPopupView {
     
     func update(_ detail: LNQRCodeDetailResponse, count: Int, extra: String) {
         gameNameLabel.text = detail.bizCategoryName
-        avatar.sd_setImage(with: URL(string: detail.avatar))
+        avatar.showAvatar(detail.avatar)
         nameLabel.text = detail.nickname
         priceLabel.text = "\(detail.price.toDisplay)/\(detail.unit)"
         

+ 2 - 2
Lanu/Views/Order/Create/LNCreateOrderViewController.swift

@@ -97,7 +97,7 @@ extension LNCreateOrderViewController: UITextFieldDelegate {
 
 extension LNCreateOrderViewController {
     private func updateContent(_ detail: LNGameMateSkillDetailVO) {
-        avatar.sd_setImage(with: URL(string: detail.avatar))
+        avatar.showAvatar(detail.avatar)
         nameLabel.text = detail.nickname
         starLabel.text = "\(detail.star)"
         
@@ -113,7 +113,7 @@ extension LNCreateOrderViewController {
     }
     
     private func updateContent(_ detail: LNQRCodeDetailResponse) {
-        avatar.sd_setImage(with: URL(string: detail.avatar))
+        avatar.showAvatar(detail.avatar)
         nameLabel.text = detail.nickname
         starLabel.text = "\(detail.star)"
         

+ 1 - 1
Lanu/Views/Order/Detail/LNOrderDetailCardView.swift

@@ -39,7 +39,7 @@ class LNOrderDetailCardView: UIView {
     }
     
     func update(_ item: LNOrderDetailResponse) {
-        avatar.sd_setImage(with: URL(string: item.orderInfo.avatar))
+        avatar.showAvatar(item.orderInfo.avatar)
         nameLabel.text = item.orderInfo.nickname
         gameLabel.text = item.orderInfo.bizCategoryName
         priceLabel.text = "\(item.orderInfo.price.toDisplay)"

+ 1 - 1
Lanu/Views/Order/OrderList/LNOrderListItemCell.swift

@@ -34,7 +34,7 @@ class LNOrderListItemCell: UITableViewCell {
     }
     
     func update(_ item: LNOrderListItemVO) {
-        avatar.sd_setImage(with: URL(string: item.avatar))
+        avatar.showAvatar(item.avatar)
         dateLabel.text = TimeInterval(item.createTime / 1_000).formattedFullDate()
         userNameLabel.text = item.nickname
         gameLabel.text = item.bizCategoryName

+ 2 - 2
Lanu/Views/Order/OrderQR/LNOrderShareImageGenerator.swift

@@ -28,7 +28,7 @@ class LNOrderShareImageGenerator {
     }
     
     func update(skill: LNGameMateSkillVO, count: Int, image: UIImage) {
-        avatar.sd_setImage(with: URL(string: myUserInfo.avatar))
+        avatar.showAvatar(myUserInfo.avatar)
         skillIc.sd_setImage(with: URL(string: skill.icon))
         skillNameLabel.text = skill.name
         scoreView.score = myUserInfo.star
@@ -65,7 +65,7 @@ extension LNOrderShareImageGenerator {
         avatar.layer.borderWidth = 2
         avatar.layer.borderColor = UIColor.fill.cgColor
         avatar.clipsToBounds = true
-        avatar.sd_setImage(with: URL(string: myUserInfo.avatar))
+        avatar.showAvatar(myUserInfo.avatar)
         container.addSubview(avatar)
         avatar.snp.makeConstraints { make in
             make.centerX.equalToSuperview()

+ 1 - 1
Lanu/Views/Order/OrderRecords/LNOrderRecordCell.swift

@@ -53,7 +53,7 @@ class LNOrderRecordCell: UITableViewCell {
         priceLabel.text = item.price.toDisplay
         countLabel.text = "\(item.unit) x \(item.purchaseQty)"
         
-        avatar.sd_setImage(with: URL(string: item.avatar))
+        avatar.showAvatar(item.avatar)
         nameLabel.text = item.nickname
         genderView.image = switch item.gender {
         case .unknow: nil

+ 1 - 1
Lanu/Views/Profile/Mine/LNMineUserInfoView.swift

@@ -36,7 +36,7 @@ class LNMineUserInfoView: UIView {
 extension LNMineUserInfoView: LNProfileManagerNotify, LNRelationManagerNotify {
     func onUserInfoChanged(userInfo: LNUserProfileVO) {
         guard userInfo.userNo.isMyUid else { return }
-        avatar.sd_setImage(with: URL(string: userInfo.avatar), placeholderImage: .icProfileLoginAvatar)
+        avatar.showAvatar(userInfo.avatar)
         nameLabel.text = userInfo.nickname
         idLabel.text = userInfo.userNo
     }

+ 2 - 2
Lanu/Views/Profile/Profile/LNProfileViewController.swift

@@ -116,13 +116,13 @@ extension LNProfileViewController {
         guard let detail else { return }
         hasFollow = detail.follow
         
-        avatar.sd_setImage(with: URL(string: detail.avatar))
+        avatar.showAvatar(detail.avatar)
         titleLabel.text = detail.nickname
         shareButton.isHidden = !detail.playmate || !detail.userNo.isMyUid
         editButton.isHidden = !detail.userNo.isMyUid
         moreButton.isHidden = detail.userNo.isMyUid
         
-        cover.sd_setImage(with: URL(string: detail.avatar))
+        cover.showAvatar(detail.avatar)
         userInfoView.update(detail)
         voiceBar.update(detail.voiceBar)
         infoView.update(detail)

+ 1 - 1
Lanu/Views/Profile/Relation/LNUserRelationItemCell.swift

@@ -28,7 +28,7 @@ class LNUserRelationItemCell: UITableViewCell {
     }
     
     func update(_ item: LNRelationUserVO) {
-        avatar.sd_setImage(with: URL(string: item.avatar))
+        avatar.showAvatar(item.avatar)
         nameLabel.text = item.nickname
         genderView.update(item.gender, item.age)
         

+ 1 - 1
Lanu/Views/Search/LNUserSearchItemCell.swift

@@ -29,7 +29,7 @@ class LNUserSearchItemCell: UITableViewCell {
     }
     
     func update(_ item: LNGameMateSearchResultVO) {
-        avatar.sd_setImage(with: URL(string: item.avatar))
+        avatar.showAvatar(item.avatar)
         onlineView.isHidden = !item.online
         nameLabel.text = item.nickname
         genderView.update(item.gender, item.age)

+ 1 - 1
Lanu/Views/Search/LNUserSearchViewController.swift

@@ -217,7 +217,7 @@ extension LNUserSearchViewController {
         container.layer.cornerRadius = 18
         container.snp.makeConstraints { make in
             make.height.equalTo(36)
-            make.width.equalTo(view.bounds.width).priority(.low)
+            make.width.equalTo(view.bounds.width).priority(.medium)
         }
         
         let ic = UIImageView()