当前位置: 首页 > 知识库问答 >
问题:

使用Unity3D和OneSignal订阅推送通知时,iOs因NSInvalidArgumentException而崩溃

仇阳州
2023-03-14

我用Unity3D制作了一个游戏/应用程序,需要设置一个推送通知的OneSignal。它在Android上工作得很好,我已经测试并发布了它。现在,用iOs真实设备测试给了我一个例外,并使我的应用程序崩溃。

我遵循了他们在这里找到的实现步骤:https://documentation.onesignal.com/docs/unity-sdk-setup

我试过在iPhone7 Plus、iPad和模拟器上运行。模拟器工作得很好,并在OneSignal上注册(push不工作,因为它不受支持,但它在那里显示)。所有其他真正的设备都会崩溃。

    null

结果:效果很好!一点问题都没有

--

尝试:在Target>Capabilites下:应用程序组启用,后台模式/远程通知启用,推送通知启用(如上面的链接)。

尝试:在Target>Capabilites下:启用应用程序组,禁用后台模式/html" target="_blank">远程通知,启用推送通知。

结果:应用程序启动并请求推送通知权限。当我允许的时候就会崩溃。

--

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) 

共有1个答案

邢思淼
2023-03-14

我在2.8.2版本中也有类似的问题,我为OneSignal开发人员创建了问题:https://github.com/OneSignal/onesignal-unity-sdk/issues/218

所以这就是SDK的bug。

解决方案:您可以尝试使用OneSignal 2.8.1。对我有用。

 类似资料:
  • 我开发了一个React Native应用程序,当应用程序处于活动状态时,每次收到来自OneSignal的消息推送时都会崩溃。 错误是。 如果我在应用程序处于后台时收到通知,则没有问题。 这是我的身材。gradle文件: 还有我的应用/构建。gradle文件: 你知道问题来自哪里吗?

  • 我已经检查了react native onesignal github README,似乎获得通知的唯一方法是通过onNotificationOpen()回调打开。 他们的文件表明: 当打开或接收到任何通知时,调用回调传递带有通知数据的对象。 但是,显然不起作用。 有没有办法在不打开推送通知或启用应用内警报通知的情况下获取通知?

  • 我在项目中设置了react native onesignal,以使用onesignal实现推送通知。 从Xcode 11.4 Beta开始,可以在iOS模拟器上测试推送通知。我创建了JSON格式的apns文件来测试模拟器上的推送通知,它运行得非常好。 但我如何模拟OneSignal推送通知呢? 我遵循OneSignal文档并希望接收从OneSignal仪表板发送的推送通知。 以下是我在应用程序上实

  • 每当向特定玩家ID发送通知时,具有该玩家ID的用户将被取消订阅。发送通知之前的状态在OneSignal仪表板中订阅。设备上没有收到任何通知。从REST API发送的所有相应通知都将响应返回为错误: 环境 OneSignal SDK-“react-native OneSignal”:“^3.3.2”react-native版本-“react-native”:“^0.60.4”,

  • 我一直在和Redis和Faye玩一个我正在构建的系统。我仍然不确定它们是否是我具体应用的最佳选择。 我的目标 每个用户都可以向频道/主题发布消息,并从他订阅的主题接收消息。主题必须具有层次结构(即主题“B”是主题“a”的子主题,因此我们有一个“a”)- 用户应该使用推送通知(Android/苹果)在手机上接收通知。 我想做的 我试图通过向层次结构的所有通道发布消息来模拟层次结构。假设我们有这样的等

  • 问题内容: 我已经在项目中实现了推送通知,到目前为止一切正常。我尝试过通过Pusher发送通知,但效果很好。但是我必须通过PHP发送它们,但尚无法使用。我发现了许多有关如何实现此目标的旧解释,但似乎没有一个对我有用。 这就是我要使用的方法: 问题答案: 尝试使用此php脚本,确保.pem证书在运行时以与该php脚本相同的路径退出,并获得正确的设备令牌