我的问题:
我用Unity3D制作了一个游戏/应用程序,需要为推送通知设置一个信号。
它很适合Android,我已经测试并发布了它。现在,使用iOs real设备进行测试会给我一个异常,并导致我的应用程序崩溃。
我遵循了这里的实现步骤:
https://documentation.onesignal.com/docs/unity-sdk-setup
我试过在iPhone 7 Plus、iPad和模拟器上运行。模拟器工作得很好,并在一个信号上注册(push不工作,因为它不受支持,但显示在那里)。所有其他真正的设备都崩溃了。
另外,我根本不是一个objective-c/xcode/iOs专家。我知道很多语言,但objective-c不是其中之一。
我的版本:
XCode版本10.3(10G8)
Unity版本2019.2.5f1
OneSignal Unity SDK版本2.8.2
我的尝试:
尝试:在Android设备上运行
结果:效果很好!一点问题都没有
--
尝试:在“目标>功能:启用应用程序组”、“启用后台模式/远程通知”、“启用推送通知”(如上面的链接)下。
结果:应用程序在启动时崩溃。
--
尝试过:同上,但关闭了Wi-Fi。
结果:正常工作,但没有注册OneSignal,因为它没有internet连接。
--
尝试:在“目标>功能:启用应用程序组”、“禁用后台模式/远程通知”、“启用推送通知”下。
结果:应用程序启动并请求推送通知权限。当我允许的时候就崩溃了。
--
已尝试:对OneSignalNotificationServiceExtension目标启用上述相同选项
结果:没有变化,像以前一样崩溃。
错误日志:
在任何崩溃中,都会发生相同的错误。
(为了保护客户的隐私,我已将app name更改为APPNAME。)

2019-09-12 13:33:05.883 APPNAME[1120:325776] UnityIAP UnityEarlyTransactionObserver: Created
2019-09-12 13:33:05.890 APPNAME[1120:325776] UnityIAP UnityEarlyTransactionObserver: Registered for lifecycle events
CrashReporter: initialized
2019-09-12 13:33:06.180 APPNAME[1120:325776] Built from '2019.2/staging' branch, Version '2019.2.5f1 (9dace1eed4cc)', Build type 'Release', Scripting Backend 'il2cpp'
2019-09-12 13:33:06.219 APPNAME[1120:325776] -> registered mono modules 0x158e810
2019-09-12 13:33:06.471 APPNAME[1120:325776] You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.
-> applicationDidFinishLaunching()
2019-09-12 13:33:06.978 APPNAME[1120:325776] Metal GPU Frame Capture Enabled
2019-09-12 13:33:06.979 APPNAME[1120:325776] Metal API Validation Disabled
2019-09-12 13:33:07.507 APPNAME[1120:325776] UnityIAP UnityEarlyTransactionObserver: Added to the payment queue
-> applicationDidBecomeActive()
[XR] Discovering subsystems at path /var/containers/Bundle/Application/493D8CF2-4D91-4035-9256-8E7A53D7FB4A/APPNAME.app/Data/UnitySubsystems
GfxDevice: creating device client; threaded=1
Renderer: PowerVR SGX 543
Vendor:   Imagination Technologies
Version:  OpenGL ES 2.0 IMGSGX543-124.1
GLES:     2
 GL_OES_depth_texture GL_OES_depth24 GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_mapbuffer GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_vertex_array_object GL_EXT_blend_minmax GL_EXT_color_buffer_half_float GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_discard_framebuffer GL_EXT_draw_instanced GL_EXT_instanced_arrays GL_EXT_map_buffer_range GL_EXT_occlusion_query_boolean GL_EXT_pvrtc_sRGB GL_EXT_read_format_bgra GL_EXT_separate_shader_objects GL_EXT_shader_framebuffer_fetch GL_EXT_shader_texture_lod GL_EXT_shadow_samplers GL_EXT_sRGB GL_EXT_texture_filter_anisotropic GL_EXT_texture_rg GL_EXT_texture_storage GL_APPLE_clip_distance GL_APPLE_color_buffer_packed_float GL_APPLE_copy_texture_levels GL_APPLE_framebuffer_multisample GL_APPLE_rgb_422 GL_APPLE_sync GL_APPLE_texture_format_BGRA8888 GL_APPLE_texture_max_level GL_APPLE_texture_packed_float GL_IMG_read_format GL_IMG_texture_com
pression_pvrtc
OPENGL LOG: Creating OpenGL ES 2.0 graphics device ; Context level  <OpenGL ES 2.0> ; Context handle 359478480
Initialize engine version: 2019.2.5f1 (9dace1eed4cc)
CrashReporter: No pending report exists at /var/mobile/Containers/Data/Application/FF47706A-E2CD-4895-8DDC-0C80ECA7CD0D/Library/Caches/CrashReports/crash-pending.plcrash
2019-09-12 13:33:09.173 APPNAME[1120:325776] WARNING: OneSignal has detected that your application delegate implements a deprecated method (application:didReceiveLocalNotification:). Please note that this method has been officially deprecated and the OneSignal SDK will no longer call it. You should use UNUserNotificationCenter instead
2019-09-12 13:33:09.176 APPNAME[1120:325776] WARNING: OneSignal has detected that your application delegate implements a deprecated method (application:handleActionWithIdentifier:forLocalNotification:completionHandler:). Please note that this method has been officially deprecated and the OneSignal SDK will no longer call it. You should use UNUserNotificationCenter instead
UnloadTime: 24.191250 ms
Initializing UnityPurchasing via Codeless IAP
UnityEngine.Purchasing.CodelessIAPStoreListener:get_Instance()

(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

UnityIAP Version: 1.22.0
UnityEngine.Purchasing.StandardPurchasingModule:Instance(AppStore)
UnityEngine.Purchasing.CodelessIAPStoreListener:get_Instance()

(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2019-09-12 13:33:12.759 APPNAME[1120:325776] WARNING: OneSignal has detected that your application delegate implements a deprecated method (application:didReceiveLocalNotification:). Please note that this method has been officially deprecated and the OneSignal SDK will no longer call it. You should use UNUserNotificationCenter instead
2019-09-12 13:33:12.760 APPNAME[1120:325776] WARNING: OneSignal has detected that your application delegate implements a deprecated method (application:handleActionWithIdentifier:forLocalNotification:completionHandler:). Please note that this method has been officially deprecated and the OneSignal SDK will no longer call it. You should use UNUserNotificationCenter instead
-> applicationWillResignActive()
-> applicationDidBecomeActive()
Using configuration builder objects
UnityEngine.Purchasing.StoreCatalogImpl:handleCachedCatalog(Action`1)
UnityEngine.Purchasing.<Process>d__4:System.IDisposable.Dispose()

(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2019-09-12 13:33:15.912 APPNAME[1120:325776] UnityIAP: Requesting 1 products
2019-09-12 13:33:15.915 APPNAME[1120:325776] UnityIAP: Requesting product data...
2019-09-12 13:33:17.167 APPNAME[1120:325776] UnityIAP: Received 1 products
2019-09-12 13:33:17.192 APPNAME[1120:325776] UnityIAP: No App Receipt found
2019-09-12 13:33:17.207 APPNAME[1120:325776] UnityIAP: No App Receipt found
UnityIAP: Promo interface is available for 1 items
UnityEngine.Purchasing.Promo:ProvideProductsToAds(HashSet`1)
UnityEngine.Purchasing.AppleStoreImpl:OnProductsRetrieved(String)
System.Action:Invoke()
UnityEngine.Purchasing.Extension.UnityUtil:Update()

(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2019-09-12 13:33:17.219 APPNAME[1120:325776] UnityIAP: Add transaction observer
2019-09-12 13:33:17.221 APPNAME[1120:325776] UnityIAP UnityEarlyTransactionObserver: Request to initiate queued payments
2019-09-12 13:33:19.375 APPNAME[1120:325776] +[NSString hexStringFromData:]: unrecognized selector sent to class 0x3b1c52dc
2019-09-12 13:33:19.791 APPNAME[1120:325776] Uncaught exception: NSInvalidArgumentException: +[NSString hexStringFromData:]: unrecognized selector sent to class 0x3b1c52dc
(
    0   CoreFoundation                      0x2406f933 <redacted> + 150
    1   libobjc.A.dylib                     0x2380ae17 objc_exception_throw + 38
    2   CoreFoundation                      0x240751d1 <redacted> + 0
    3   CoreFoundation                      0x24072ee1 <redacted> + 700
    4   CoreFoundation                      0x23f9e238 _CF_forwarding_prep_0 + 24
    5   APPNAME                     0x014af3c9 +[OneSignal didRegisterForRemoteNotifications:deviceToken:] + 90
    6   APPNAME                     0x014c1447 -[OneSignalAppDelegate oneSignalDidRegisterForRemoteNotifications:deviceToken:] + 90
    7   libdispatch.dylib                   0x23bdd823 <redacted> + 10
    8   libdispatch.dylib                   0x23bdd80f <redacted> + 22
    9   libdispatch.dylib                   0x23bebba9 <redacted> + 1524
    10  Cowarning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.
reFoundation                      0x24031b6d <redacted> + 8
    11  CoreFoundation                      0x24030067 <redacted> + 1574
    12  CoreFoundation                      0x23f7f229 CFRunLoopRunSpecific + 520
    13  CoreFoundation                      0x23f7f015 CFRunLoopRunInMode + 108
    14  GraphicsServices                    0x2556fac9 GSEventRunModal + 160
    15  UIKit                               0x28653189 UIApplicationMain + 144
    16  APPNAME                     0x000844bb main + 202
    17  libdyld.dylib                       0x23c27873 <redacted> + 2
)
(lldb)

其他详细信息:
我不知道它是否改变了什么,但是我在Target>Capabilities>App Groups下得到了这个错误:
我尝试在构建时禁用应用程序组,但没有改变。

最佳答案

我在版本2.8.2中遇到了类似的问题,我为OneSignal开发人员创建了问题:
https://github.com/OneSignal/OneSignal-Unity-SDK/issues/218
这就是sdk的缺陷。
解决方案:可以尝试使用OneSignal 2.8.1。对我有用。

关于ios - 使用Unity3D和OneSignal订阅推送通知时,iOS崩溃,并显示NSInvalidArgumentException,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57911442/

10-13 07:34