uni-app 3.3.13版本后离线打包iOS无法推送 获取不到设备ID

uni-app 3.3.13版本后离线打包iOS无法推送 获取不到设备ID

开发环境 版本号 项目创建方式
Mac 12 HBuilderX

产品分类:uniapp/App
PC开发环境操作系统:Mac
HBuilderX类型:正式
HBuilderX版本号:3.3.13
手机系统:iOS
手机系统版本号:iOS 15
手机厂商:苹果
手机机型:SE2
页面类型:vue
vue版本:vue2
打包方式:离线
App下载地址或H5网址:itunes.apple.com/cn/app/%E7%A6%8F%E5%AE%B6%E4%BA%AB%E5%8F%97/id1531669972?mt=8

示例代码:

(void)mystartSdkWithAppId:(NSString *)appid appKey:(NSString *)appKey appSecret:(NSString *)appSecret delegate:(id<GeTuiSdkDelegate>)delegate{  
NSLog(@"%@", [NSString stringWithFormat:@"GeTuiSdk (GPush): mystartSdkWithAppId: %@ appKey:%@ appSecret:%@ delegate:%@",appid, appKey, appSecret, delegate]);  
[GeTuiSdk mystartSdkWithAppId:appid appKey:appKey appSecret:appSecret delegate:delegate];
}  

3.3.13 SDK执行  
2022-04-24 12:20:41.687248+0800 HBuilder[74037:2975985] GeTuiSdk (GPush): +load  
2022-04-24 12:20:41.727377+0800 HBuilder[74037:2975985] NSDictionary (GPush): +load  
2022-04-24 12:20:46.332257+0800 HBuilder[74037:2975985] -canOpenURL: failed for URL: "taobao://" - error: "This app is not allowed to query for scheme taobao"  
2022-04-24 12:20:46.332650+0800 HBuilder[74037:2975985] -canOpenURL: failed for URL: "kwai://" - error: "This app is not allowed to query for scheme kwai"  
2022-04-24 12:20:46.332989+0800 HBuilder[74037:2975985] -canOpenURL: failed for URL: "awemesso://" - error: "This app is not allowed to query for scheme awemesso"  
2022-04-24 12:20:46.333325+0800 HBuilder[74037:2975985] -canOpenURL: failed for URL: "pinduoduo://" - error: "This app is not allowed to query for scheme pinduoduo"  
2022-04-24 12:20:46.333725+0800 HBuilder[74037:2975985] -canOpenURL: failed for URL: "openApp.jdMobile://" - error: "This app is not allowed to query for scheme openapp.jdmobile"  
2022-04-24 12:20:46.337609+0800 HBuilder[74037:2975985] ######===>New Device Model:[iPhone12,8]  
2022-04-24 12:20:46.447830+0800 HBuilder[74037:2975985] [Runtime][DEBUG:] ##CoreApp##...app start load..  
2022-04-24 12:20:46.448311+0800 HBuilder[74037:2975985] [Runtime][DEBUG:] ##CoreApp##...createAppRuntime..  
2022-04-24 12:20:46.452333+0800 HBuilder[74037:2975985] UniPluginProtocol Func: <HXUniNativePluginProxy: 0x283e59aa0>,-[HXUniNativePluginProxy onCreateUniPlugin]  
2022-04-24 12:20:46.453318+0800 HBuilder[74037:2975985] UniPluginProtocol Func: <HXUniNativePluginProxy: 0x283e59aa0>,-[HXUniNativePluginProxy application:didFinishLaunchingWithOptions:]  
2022-04-24 12:20:46.465784+0800 HBuilder[74037:2975985] ### huisu addObserver ###  
2022-04-24 12:20:46.565884+0800 HBuilder[74037:2975985] [Runtime][DEBUG:] splash screen 需要自动关闭  
2022-04-24 12:20:46.580909+0800 HBuilder[74037:2975985] [Runtime][DEBUG:] core started  
2022-04-24 12:20:46.581484+0800 HBuilder[74037:2975985] application--didRegisterForRemoteNotificationsWithDeviceToken[{length = 32, bytes = 0xe7465355 7dba2d13 2bbdb0c7 9ec6f995 ... 573a7405 21906961 }]  
2022-04-24 12:20:46.581574+0800 HBuilder[74037:2975985] deviceToken1:e74653557dba2d132bbdb0c79ec6f995195870b2a0729065573a740521906961  
2022-04-24 12:20:46.583100+0800 HBuilder[74037:2975985] UniPluginProtocol Func: <HXUniNativePluginProxy: 0x283e59aa0>,-[HXUniNativePluginProxy applicationDidBecomeActive:]  

3.3.11 SDK执行

2022-04-24 12:22:01.585256+0800 HBuilder[74054:2977061] GeTuiSdk (GPush): +load
2022-04-24 12:22:01.626538+0800 HBuilder[74054:2977061] NSDictionary (GPush): +load
2022-04-24 12:22:01.855935+0800 HBuilder[74054:2977061] -canOpenURL: failed for URL: “taobao://” - error: “This app is not allowed to query for scheme taobao”
2022-04-24 12:22:01.856398+0800 HBuilder[74054:2977061] -canOpenURL: failed for URL: “kwai://” - error: “This app is not allowed to query for scheme kwai”
2022-04-24 12:22:01.856719+0800 HBuilder[74054:2977061] -canOpenURL: failed for URL: “awemesso://” - error: “This app is not allowed to query for scheme awemesso”
2022-04-24 12:22:01.857422+0800 HBuilder[74054:2977061] -canOpenURL: failed for URL: “pinduoduo://” - error: “This app is not allowed to query for scheme pinduoduo”
2022-04-24 12:22:01.857751+0800 HBuilder[74054:2977061] -canOpenURL: failed for URL: “openApp.jdMobile://” - error: “This app is not allowed to query for scheme openapp.jdmobile”
2022-04-24 12:22:01.861488+0800 HBuilder[74054:2977061] ######===>New Device Model:[iPhone12,8]
2022-04-24 12:22:02.010201+0800 HBuilder[74054:2977061] GeTuiSdk–PGPushServerAct
2022-04-24 12:22:02.011150+0800 HBuilder[74054:2977061] GeTuiSdk (GPush): mystartSdkWithAppId: *** appKey:*** appSecret:*** delegate:<PGPushServerAct: 0x282587c80>
2022-04-24 12:22:02.026428+0800 HBuilder[74054:2977061] GeTuiSdk (GPush): myclientId: 195f0f5011477927b6e2eb7ba286c719
2022-04-24 12:22:02.027018+0800 HBuilder[74054:2977061] [Runtime][DEBUG:] ##CoreApp##…app start load…
2022-04-24 12:22:02.027387+0800 HBuilder[74054:2977061] [Runtime][DEBUG:] ##CoreApp##…createAppRuntime…
2022-04-24 12:22:02.031317+0800 HBuilder[74054:2977061] UniPluginProtocol Func: <HXUniNativePluginProxy: 0x283286ef0>,-[HXUniNativePluginProxy onCreateUniPlugin]
2022-04-24 12:22:02.031938+0800 HBuilder[74054:2977061] UniPluginProtocol Func: <HXUniNativePluginProxy: 0x283286ef0>,-[HXUniNativePluginProxy application:didFinishLaunchingWithOptions:]
2022-04-24 12:22:02.043136+0800 HBuilder[74054:2977061] ### huisu addObserver ###
2022-04-24 12:22:02.101488+0800 HBuilder[74054:2977061] [Runtime][DEBUG:] splash screen 需要自动关闭
2022-04-24 12:22:02.108856+0800 HBuilder[74054:2977061] [Runtime][DEBUG:] core started
2022-04-24 12:22:02.109291+0800 HBuilder[74054:2977061]
2022-04-24 12:22:02.109385+0800 HBuilder[74054:2977061] [GexinSdk error]:Missing UNUserNotificationCenter Delegate, Please Use [GeTuiSdk registerRemoteNotification:]
2022-04-24 12:22:02.109432+0800 HBuilder[74054:2977061] application–didRegisterForRemoteNotificationsWithDeviceToken[{length = 32, bytes = 0xe7465355 7dba2d13 2bbdb0c7 9ec6f995 … 573a7405 21906961 }]
2022-04-24 12:22:02.109531+0800 HBuilder[74054:2977061] GeTuiSdk–registerDeviceTokenData[{length = 32, bytes = 0xe7465355 7dba2d13 2bbdb0c7 9ec6f995 … 573a7405 21906961 }]
2022-04-24 12:22:02.109630+0800 HBuilder[74054:2977061] deviceToken1:e74653557dba2d132bbdb0c79ec6f995195870b2a0729065573a740521906961
2022-04-24 12:22:02.110927+0800 HBuilder[74054:2977061] UniPluginProtocol Func: <HXUniNativePluginProxy: 0x283286ef0>,-[HXUniNativePluginProxy applicationDidBecomeActive:]


其余日志  

2022-04-23 14:10:57.184481+0800 HBuilder[464:12466] [Runtime][DEBUG:] core started  
2022-04-23 14:10:57.185349+0800 HBuilder[464:12466] UniPluginProtocol Func: <HXUniNativePluginProxy: 0x2818a6df0>,-[HXUniNativePluginProxy applicationDidBecomeActive:]  
2022-04-23 14:10:57.185491+0800 HBuilder[464:12466] application--didRegisterForRemoteNotificationsWithDeviceToken[{length = 32, bytes = 0x31dce6fa e0a20a96 6de6b884 6db0d699 ... 05feac05 184ccd93 }]  
2022-04-23 14:10:57.185539+0800 HBuilder[464:12466] deviceToken1:31dce6fae0a20a966de6b8846db0d699c7625535cac45fb705feac05184ccd93  

2022-04-23 14:11:07.860218 0800 HBuilder[464:12696] <Weex>[log]WXBridgeContext.m:1310, jsLog: #ifdef APP-PLUS tryToUploadCid at pages/index/index.vue:2329 LOG  
2022-04-23 14:11:07.863084 0800 HBuilder[464:12696] <Weex>[log]WXBridgeContext.m:1310, jsLog: Push:用户已经登录: UR000002856682,getClientInfo:cid: undefined at pages/index/index.vue:2334 LOG  
2022-04-23 14:11:07.863569 0800 HBuilder[464:12696] <Weex>[log]WXBridgeContext.m:1310, jsLog: Push:用户已经登录: UR000002856682, getClientInfo cid: null at pages/index/index.vue:2340 LOG  
2022-04-23 14:11:07.867472 0800 HBuilder[464:12696] <Weex>[log]WXBridgeContext.m:1310, jsLog: RemoteNotificationsUpdateBadge: var GeTuiSdk = plus.ios.importClass('GeTuiSdk'); at pages/index/index.vue:2350 LOG  
2022-04-23 14:11:07.867739 0800 HBuilder[464:12696] <Weex>[log]WXBridgeContext.m:1310, jsLog: RemoteNotificationsUpdateBadge: GeTuiSdk != null at pages/index/index.vue:2352 LOG  
2022-04-23 14:11:07.868300 0800 HBuilder[464:12696] <Weex>[log]WXBridgeContext.m:1310, jsLog: Push:用户已经登录: UR000002856682, GeTuiSdk.clientId()---COMMA------UNDEFINED--- at pages/index/index.vue:2355 LOG  
2022-04-23 14:11:10.866213 0800 HBuilder[464:12696] <Weex>[log]WXBridgeContext.m:1310, jsLog: #ifdef APP-PLUS tryToUploadCid at pages/index/index.vue:2329 LOG  
2022-04-23 14:11:10.868547 0800 HBuilder[464:12696] <Weex>[log]WXBridgeContext.m:1310, jsLog: Push:用户已经登录: UR000002856682,getClientInfo:cid: undefined at pages/index/index.vue:2334 LOG  
2022-04-23 14:11:10.868991 0800 HBuilder[464:12696] <Weex>[log]WXBridgeContext.m:1310, jsLog: Push:用户已经登录: UR000002856682, getClientInfo cid: null at pages/index/index.vue:2340 LOG  
2022-04-23 14:11:10.872874 0800 HBuilder[464:12696] <Weex>[log]WXBridgeContext.m:1310, jsLog: RemoteNotificationsUpdateBadge: var GeTuiSdk = plus.ios.importClass('GeTuiSdk'); at pages/index/index.vue:2350 LOG  
2022-04-23 14:11:10.873155 0800 HBuilder[464:12696] <Weex>[log]WXBridgeContext.m:1310, jsLog: RemoteNotificationsUpdateBadge: GeTuiSdk != null at pages/index/index.vue:2352 LOG  
2022-04-23 14:11:10.873697 0800 HBuilder[464:12696] <Weex>[log]WXBridgeContext.m:1310, jsLog: Push:用户已经登录: UR000002856682, GeTuiSdk.clientId()---COMMA------UNDEFINED--- at pages/index/index.vue:2355 LOG  

更多关于uni-app 3.3.13版本后离线打包iOS无法推送 获取不到设备ID的实战教程也可以访问 https://www.itying.com/category-93-b0.html

7 回复

注意 SDK目录下的 /SDK/Bundles/PandoraApi.bundle/feature.plist,如果之前有修改过需要开发者自行备份,升级完SDK再次覆盖此文件,避免升级造成部分功能异常
看下这个文件配的对不对

更多关于uni-app 3.3.13版本后离线打包iOS无法推送 获取不到设备ID的实战教程也可以访问 https://www.itying.com/category-93-b0.html


按照配置做过多次尝试, 无论是配置 LinkerFlags 还是 Library, 在 3.3.13 后版本都没有调用GeTuiSDK中注册方法, 也下了最新 SDK, 改了包名赔了库, 但是依旧未调用

回复 n***@qq.com: 我发的plist 你检查了么

回复 DCloud_iOS_WZT: 您能请您那面的 iOS 开发工程师验证一下这个问题么, 在最新的 3.4.7 SDK 包的基础上验证一下这个问题么

回复 DCloud_iOS_WZT: 或者 SDK 中能不能把 [GeTuiSdk startSdkWithAppId:appid appKey:appKey appSecret:appSecret delegate:delegate];的调用暴露出来, 如果 SDK 有 bug 也可以让其他人主动调用

feature.plist 文件(位于PandoraApi.bundle中),Push模块下缺少class字段导致的问题

在 uni-app 3.3.13 版本后,如果离线打包 iOS 应用时无法推送且获取不到设备 ID,可能是由于以下几个原因导致的。以下是一些排查和解决问题的步骤:

1. 检查推送配置

  • APNs 证书:确保你已经正确配置了 Apple Push Notification Service (APNs) 证书,并且证书是有效的。
  • Capabilities:在 Xcode 项目中,确保已经启用了 Push NotificationsBackground Modes(勾选 Remote notifications)。

2. 检查权限配置

  • Info.plist 文件中,确保已经添加了推送通知的权限,例如:
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>我们需要您的位置信息来提供更好的服务</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>我们需要使用麦克风来录制音频</string>
    <key>NSCameraUsageDescription</key>
    <string>我们需要使用相机来拍摄照片</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>我们需要访问您的相册来选择照片</string>
    

3. 检查代码逻辑

  • 确保在 AppDelegate 中正确注册了推送通知。例如:
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // 注册推送通知
        [UNUserNotificationCenter currentNotificationCenter].delegate = self;
        [application registerForRemoteNotifications];
        return YES;
    }
    

4. 获取设备 Token

  • 确保在 AppDelegate 中实现了 didRegisterForRemoteNotificationsWithDeviceToken 方法,并且能够正确获取到设备 Token:
    - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
        // 将 deviceToken 转换为字符串
        NSString *token = [[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
        token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];
        NSLog(@"Device Token: %@", token);
    }
回到顶部