Install
openclaw skills install ios-mobpush-integration面向 iOS 工程的 MobTech MobPush 集成 skill。默认先扫描工程,优先使用 CocoaPods,以最小改动完成推送依赖接入、APNs 配置、隐私合规、回调接线和项目内说明文档落地。
openclaw skills install ios-mobpush-integration当用户希望把 MobTech MobPush 集成到 iOS 工程,或者排查已有 MobPush 接入问题时,使用本 skill。
当用户提到以下任一主题时,使用本 skill:
Info.plist 配置uploadPrivacyPermissionStatus 调用时机setupNotification / setAPNsForProduction 用法如果用户问题明确与 iOS MobPush 接入、工程配置、证书鉴权、隐私合规、通知接收、Tag/Alias 或 Live Activity 扩展能力有关,应优先使用本 skill。
优先使用以下线上资料,不依赖本机资料路径:
主文档:
扩展资料:
如果某个深链失效,先从 MobTech 文档中心 搜索对应标题,不要回退到本机绝对路径。
以下信息已经可作为执行依据,不需要再猜测:
Xcode 9.1.0+、iOS 8.0+CocoaPods 和手动导入两种集成方式pod 'mob_pushsdk'libc++.tbd、libz.1.2.5.tbdInfo.plist 需要配置 MOBAppKey 与 MOBAppSecretPush NotificationsBackground Modes 并勾选 Remote notificationsuploadPrivacyPermissionStatus 是 MobSDK 业务起点,必须在用户同意隐私政策后、使用 SDK 能力前调用plist 中增加 MOBNetLater = 2setAPNsForProduction: 在开发与生产间切换setupNotification: 配置MobPushDidReceiveMessageNotificationMobPushDidReceiveMessageNotification 在 Swift 中被重命名为 NSNotification.Name.MobPushDidReceiveMessageMPushMessage 的 msg 和 isCustomMessage 属性在 4.x 中已移除,改用 messageType(MPushMessageType.custom)和 message.notification.bodymessage.notification.userInfo["mobpushCustomTitle"] / ["mobpushCustomType"]MPushAuthorizationOptions 在 Swift 中以 OptionSet 形式可用:MPushAuthorizationOptions.badge.union(.sound).union(.alert)#import <MobPush/MobPush.h> 和 #import <MOBFoundation/MOBFoundation.h>.xcodeproj 的 Debug 和 Release 构建配置中设置 SWIFT_OBJC_BRIDGING_HEADERgetRegistrationID 必须在推送设置接口之后调用MOBFoundationPrivacyDelegate 自定义类接入.p12 与 APNs Auth Key(.p8) 两种方式.p8 鉴权需要 Key ID、Team ID、Bundle IDiOS 16.1+、SwiftUI、ActivityKit,且需要 App 运行态配合以下内容在当前资料里没有被稳定、明确地定义,禁止猜:
如果缺这些信息且会阻塞安全修改,必须明确写:
文档未明确,需向用户确认
CocoaPodsBundle ID、Target 名称、Info.plist 路径、入口类名,因为这些应由扫描工程自动推断pod install、xcodebuild 或其他会改动依赖状态的命令,先展示计划,再执行Pods/ 提交进项目;如项目未忽略 Pods/,补充 .gitignore,保留 Podfile 与 Podfile.lock严格按以下顺序推进:
优先扫描以下内容:
.xcodeproj / .xcworkspacePodfilePodfile.lockPackage.swiftAppDelegate / SceneDelegate / SwiftUI @mainInfo.plistMobPush、MOBAppKey、MOBAppSecret、MOBNetLater、uploadPrivacyPermissionStatus.gitignore 是否忽略 Pods/.xcworkspace 是否包含 contents.xcworkspacedata推荐命令:
rg --files -g '*.xcodeproj' -g '*.xcworkspace' -g 'Podfile' -g 'Podfile.lock' -g 'Package.swift' -g '*Info.plist' -g '.gitignore'rg --files -g '*.m' -g '*.h' -g '*.mm' -g '*.swift'rg -n 'MobPush|MOBAppKey|MOBAppSecret|MOBNetLater|uploadPrivacyPermissionStatus|setAPNsForProduction|setupNotification|MobPushDidReceiveMessageNotification|UNUserNotificationCenter|didRegisterForRemoteNotificationsWithDeviceToken|SWIFT_OBJC_BRIDGING_HEADER'扫描后先给一段简短结论,至少包含:
Podfile、Podfile.lock、Pods/、*.xcworkspace/contents.xcworkspacedataMobPush_iOS_Config.xlsx如果 {path} 下还没有 MobPush_iOS_Config.xlsx:
assets/generate_excel_template.pyassets/MobPush_iOS_Config_Template.xlsx 复制到 {path} 下{path} 下命名为 MobPush_iOS_Config.xlsx必须明确告诉用户只需要填写这些最小字段:
appKeyappSecretapnsAuthModeneedLiveActivity同时明确说明以下内容不需要填表:
Bundle IDTargetInfo.plist 路径Key ID / Team ID / .p12 文件路径其中工程信息应由 Agent 扫描后推断;鉴权材料属于控制台与苹果后台准备项,不应默认塞进最小模板。
读取 MobPush_iOS_Config.xlsx 后,至少校验:
appKey:必填,按字符串处理,不做数值推断appSecret:必填,按字符串处理,不做数值推断apnsAuthMode:必须明确是 p12 / p8 / 已存在needLiveActivity:必须明确是 是 / 否如不合法,列出具体问题并要求用户修正,不要继续改工程。
读取配置后,再次结合工程做推断:
{Target}-Bridging-Header.h 与 SWIFT_OBJC_BRIDGING_HEADERPush Notifications / Background Modes 相关工程配置说明或脚本*.xcworkspace 是否有效;只有目录但缺少 contents.xcworkspacedata 时,应运行 pod install 重新生成Pods/ 是否完整;如果只有空 framework 目录或缺少 Info.plist、Headers、binary,不要按手动 SDK 接入硬改工程,应优先重新 pod install以下信息必须分两类处理:
uploadPrivacyPermissionStatus 应插入到哪个“同意”回调如果必须确认,串行一次只问一个问题。
修改前必须向用户展示本次最小改动计划,通常包括:
Podfile:按需加入 pod 'mob_pushsdk'.gitignore:按需加入 Pods/Info.plist:写入 MOBAppKey、MOBAppSecret、MOBNetLater = 2Push Notifications 与 Background Modes > Remote notificationslibc++.tbd、libz.1.2.5.tbdsetAPNsForProduction:、setupNotification:uploadPrivacyPermissionStatusMobPushDidReceiveMessageNotificationgetRegistrationID 示例或落点MobPush_README.md没有确认前,不要直接改。
默认优先 CocoaPods:
Podfile 中加入 pod 'mob_pushsdk'{Target}/mobpush_bridge.h 并写入:#import <MobPush/MobPush.h>
#import <MOBFoundation/MOBFoundation.h>
.xcodeproj 的 Debug 和 Release 构建配置中设置 SWIFT_OBJC_BRIDGING_HEADER = "{Target}/mobpush_bridge.h"Podfile,先说明将新增,再等待确认如果用户明确要求手动导入:
.xcodeproj 二进制文件Info.plist至少处理以下键:
MOBAppKeyMOBAppSecretMOBNetLater = 2如果工程里已有同名键:
根据工程入口类型选择落点:
AppDelegateAppDelegate / SceneDelegate@main App 对应的 UIApplicationDelegateAdaptor最小接线包括:
DEBUG / 非 DEBUG 设置 setAPNsForProduction:MPushNotificationConfigurationsetupNotification:Swift 示例(AppDelegate 核心接线):
import UIKit
import UserNotifications
func application(_ application: UIApplication, didFinishLaunchingWithOptions: ...) -> Bool {
#if DEBUG
MobPush.setAPNsForProduction(false)
#else
MobPush.setAPNsForProduction(true)
#endif
let config = MPushNotificationConfiguration()
config.types = MPushAuthorizationOptions.badge.union(.sound).union(.alert)
MobPush.setupNotification(config)
// ⚠️ 注意使用 Swift 重命名后的常量名
NotificationCenter.default.addObserver(
self,
selector: #selector(didReceiveMobPushMessage(_:)),
name: NSNotification.Name.MobPushDidReceiveMessage,
object: nil
)
return true
}
如果工程已有自己的通知权限申请逻辑:
必须在用户同意隐私政策后插入:
MobSDK uploadPrivacyPermissionStatus:YES onResult:...如果用户拒绝隐私政策:
如果用户明确需要控制扩展业务数据采集:
MobCustomController 与 MOBFoundationPrivacyDelegate最小落地包括:
MobPushDidReceiveMessageNotificationdidReceiveMessage: 或 Swift 等价方法MPushMessage 关键字段日志或注释Swift 回调示例(注意 4.x 属性变化):
@objc private func didReceiveMobPushMessage(_ notification: Notification) {
guard let message = notification.object as? MPushMessage else { return }
switch message.messageType {
case .custom:
// 自定义消息:notification.userInfo["mobpushCustomTitle"] / ["mobpushCustomType"]
let body = message.notification.body ?? "自定义消息"
// App 内展示
default:
// 推送通知 / APNs / 本地通知
print(message.notification.body ?? "")
}
}
如果用户明确需要:
只有当用户明确要求并且工程满足 iOS 16.1+、SwiftUI、扩展 Target 条件时才执行:
NSSupportsLiveActivities = YESActivityKit.framework 与 SwiftUI.frameworkregisterLiveActivityWithID:pushToken:completion:Live Activity UI 与业务状态模型默认不代写完整业务实现,只保留官方能力落点和最小示例。
在用户确认后才执行:
pod install 或 pod updatepod install 可能因编码问题失败,需先设置环境变量:
export LANG=en_US.UTF-8 && export LC_ALL=en_US.UTF-8
pod install
*.xcworkspace验证优先级:
Podfile.lock 中确认 mob_pushsdkInfo.plist 键值存在uploadPrivacyPermissionStatus、setupNotification如果不能实际运行真机推送测试,要明确说明:
完成后在 {path} 下生成 MobPush_README.md,至少包含:
MOBAppKey / MOBAppSecret 放在哪里优先使用本 skill 内的 templates/MOBPUSH_README.md 作为骨架,再结合实际项目修改点渲染。
MobPushMOBAppKeyMOBAppSecretMOBNetLateruploadPrivacyPermissionStatussetAPNsForProductionsetupNotificationMobPushDidReceiveMessageNotificationgetRegistrationIDMOBFoundationPrivacyDelegateregisterLiveActivityWithID