Xamarin iOS崩溃与Twilio客户端

时间:2017-01-05 00:23:37

标签: twilio

我在使用Twilio客户端组件的Xamarin应用程序中崩溃了。我使用"入门"代码来制作一个简单的应用程序,当我点击一个按钮时,它会拨打电话。从崩溃日志中我看到对" CRASHING_DUE_TO_PRIVACY_VIOLATION "的引用在调用堆栈中。我不知道那可能是什么,音频和Airplay"和#34; IP语音"在我的应用程序plist文件中检查后台模式。

在模拟器中奇怪的是它完美无缺,只有当我在iPhone上运行应用程序时才会发生崩溃。我的手机正在运行ios 10.2。我包括代码和崩溃日志。请帮助,因为这个崩溃在我正在为工作而构建的应用程序中完全相同,所以我真的需要解决它而且我在我的智慧结束。

    using System;
    using UIKit;
    using Foundation;
    using TwilioClient.iOS;

    namespace twiliotest
    {
       public partial class ViewController : UIViewController
       {
          TCDevice _device;
          TCConnection _connection;

          protected ViewController(IntPtr handle) : base(handle)
         {
            // Note: this .ctor should not contain any initialization         logic.
         }

         public override void ViewDidLoad()
         {
            base.ViewDidLoad();

            string sLink = "https://www.myserver.com/captok.php";
            var url = new NSUrl(sLink);
            var data = NSData.FromUrl(url);
            var token = data.ToString();

            // Create a new TCDevice object passing in the token.
            _device = new TCDevice(token, null);
        }

        public override void DidReceiveMemoryWarning()
        {
            base.DidReceiveMemoryWarning();
        }

        partial void ButtonCall_TouchUpInside(UIButton sender)
        {
            if (_connection == null || _connection.State == TCConnectionState.Disconnected)
            {
                var param = new TCConnectionParameters
                {
                    From = "12125551234",
                    To = "12125554321"
                };
                _connection = _device.Connect(param, null);
            }
            else {
                _connection.Disconnect();
            }           
        }

        void SetupDeviceEvents()
        {
            if (_device != null)
            {
                _device.ReceivedIncomingConnection += (sender, e) =>
                {
                    _connection = e.Connection;
                    _connection.Accept();
                };
            }
        }

       }
    }

这是崩溃日志。请注意崩溃是在第7个线程中。

    Incident Identifier: FA61C36F-110A-44DF-A862-FD7C37859D8E
    CrashReporter Key:   dc2811c1cf8685a6f8963c39740ec1af0fb4e080
    Hardware Model:      iPhone7,2
    Process:             twiliotest [7846]
    Path:                /private/var/containers/Bundle/Application/412D52E2-9ECB-4C01-B984-AB2820FBBFB0/twiliotest.app/twiliotest
    Identifier:          com.davidkbowers.twiliotest
    Version:             1.0 (1.0)
    Code Type:           ARM-64 (Native)
    Role:                Foreground
    Parent Process:      launchd [1]
    Coalition:           com.davidkbowers.twiliotest [1855]


    Date/Time:           2017-01-04 18:50:06.7079 -0500
    Launch Time:         2017-01-04 18:50:00.8968 -0500
    OS Version:          iPhone OS 10.2 (14C92)
    Report Version:      104

    Exception Type:  EXC_CRASH (SIGABRT)
    Exception Codes: 0x0000000000000000, 0x0000000000000000
    Exception Note:  EXC_CORPSE_NOTIFY
    Triggered by Thread:  7

    Application Specific Information:
    abort() called

    Filtered syslog:
    None found

    Thread 0 name:  tid_403  Dispatch queue: com.apple.main-thread
    Thread 0:
    0   libsystem_kernel.dylib          0x00000001822c5188 mach_msg_trap + 8
    1   libsystem_kernel.dylib          0x00000001822c4ff8 mach_msg + 72
    2   CoreFoundation                  0x00000001832c25d0 __CFRunLoopServiceMachPort + 192
    3   CoreFoundation                  0x00000001832c01ec __CFRunLoopRun + 1132
    4   CoreFoundation                  0x00000001831ee2b8 CFRunLoopRunSpecific + 444
    5   GraphicsServices                0x0000000184ca2198 GSEventRunModal + 180
    6   UIKit                           0x00000001892357fc -[UIApplication _run] + 684
    7   UIKit                           0x0000000189230534 UIApplicationMain + 208
    8   twiliotest                      0x000000010047cd04 wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr (/<unknown>:1)
    9   twiliotest                      0x0000000100462a9c UIKit_UIApplication_Main_string___intptr_intptr (UIApplication.cs:79)
    10  twiliotest                      0x0000000100462a5c UIKit_UIApplication_Main_string___string_string (UIApplication.cs:63)
    11  twiliotest                      0x0000000100438e04 twiliotest_Application_Main_string__ (Main.cs:12)
    12  twiliotest                      0x000000010059bb64 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 244
    13  twiliotest                      0x000000010032ee28 mono_jit_runtime_invoke (mini-runtime.c:2524)
    14  twiliotest                      0x000000010039d1e8 do_runtime_invoke (object.c:2809)
    15  twiliotest                      0x000000010039f7cc mono_runtime_exec_main (object.c:4585)
    16  twiliotest                      0x000000010039f3e8 mono_runtime_run_main (object.c:4134)
    17  twiliotest                      0x0000000100314050 mono_jit_exec (driver.g.c:1048)
    18  twiliotest                      0x0000000100438bd0 xamarin_main (monotouch-main.m:487)
    19  twiliotest                      0x00000001005ec148 main (main.arm64.m:45)
    20  libdyld.dylib                   0x00000001821d15b8 start + 4

    Thread 1:
    0   libsystem_kernel.dylib          0x00000001822e3a88 __workq_kernreturn + 8
    1   libsystem_pthread.dylib         0x00000001823a7344 _pthread_wqthread + 1452
    2   libsystem_pthread.dylib         0x00000001823a6d8c start_wqthread + 4

    Thread 2:
    0   libsystem_pthread.dylib         0x00000001823a6d88 start_wqthread + 0

    Thread 3 name:  Dispatch queue: com.twilio.TCCommandHandler.commandQ
    Thread 3:
    0   libsystem_kernel.dylib          0x00000001822c5188 mach_msg_trap + 8
    1   libsystem_kernel.dylib          0x00000001822c4ff8 mach_msg + 72
    2   AudioToolbox                    0x0000000186313c90 AUIOClient_Initialize + 228
    3   AudioToolbox                    0x00000001861a1864 AURemoteIO::Initialize() + 1328
    4   AudioToolbox                    0x000000018649c3b0 AUBase::DoInitialize() + 48
    5   AudioToolbox                    0x00000001864a4888 AUMethodInitialize(void*) + 76
    6   twiliotest                      0x00000001002251d8 create_audio_unit (coreaudio_dev.m:1507)
    7   twiliotest                      0x0000000100224c7c ca_factory_create_stream (coreaudio_dev.m:1599)
    8   twiliotest                      0x0000000100233d4c twilio_pjmedia_aud_stream_create (audiodev.c:790)
    9   twiliotest                      0x00000001002319d4 twilio_pjmedia_snd_port_create2 (sound_port.c:261)
    10  twiliotest                      0x0000000100241cec open_snd_dev (pjsua_aud.c:1715)
    11  twiliotest                      0x00000001002422d8 twilio_pjsua_set_snd_dev (pjsua_aud.c:1974)
    12  twiliotest                      0x0000000100213998 twilio_pjsua_call_make_call (pjsua_call.c:645)
    13  twiliotest                      0x00000001001f7090 -[TCCall makeCall] (TCCall.m:51)
    14  twiliotest                      0x00000001001e04a4 -[TCMakeCallCommand run] (TCCommands.m:215)
    15  libdispatch.dylib               0x000000018219e1fc _dispatch_call_block_and_release + 24
    16  libdispatch.dylib               0x000000018219e1bc _dispatch_client_callout + 16
    17  libdispatch.dylib               0x00000001821ac3dc _dispatch_queue_serial_drain + 928
    18  libdispatch.dylib               0x00000001821a19a4 _dispatch_queue_invoke + 652
    19  libdispatch.dylib               0x00000001821ac8d8 _dispatch_queue_override_invoke + 360
    20  libdispatch.dylib               0x00000001821ae34c _dispatch_root_queue_drain + 572
    21  libdispatch.dylib               0x00000001821ae0ac _dispatch_worker_thread3 + 124
    22  libsystem_pthread.dylib         0x00000001823a72a0 _pthread_wqthread + 1288
    23  libsystem_pthread.dylib         0x00000001823a6d8c start_wqthread + 4

    Thread 4 name:  SGen worker
    Thread 4:
    0   libsystem_kernel.dylib          0x00000001822e2e1c __psynch_cvwait + 8
    1   libsystem_pthread.dylib         0x00000001823a89c0 _pthread_cond_wait + 640
    2   twiliotest                      0x00000001003fa544 thread_func (mono-os-mutex.h:108)
    3   libsystem_pthread.dylib         0x00000001823a9850 _pthread_body + 240
    4   libsystem_pthread.dylib         0x00000001823a9760 _pthread_body + 0
    5   libsystem_pthread.dylib         0x00000001823a6d94 thread_start + 4

    Thread 5 name:  Finalizer
    Thread 5:
    0   libsystem_kernel.dylib          0x00000001822c51c4 semaphore_wait_trap + 8
    1   twiliotest                      0x00000001003613f8 finalizer_thread (mono-os-semaphore.h:73)
    2   twiliotest                      0x00000001003ce664 start_wrapper (threads.c:740)
    3   twiliotest                      0x000000010041efbc inner_start_thread (mono-threads-posix.c:92)
    4   libsystem_pthread.dylib         0x00000001823a9850 _pthread_body + 240
    5   libsystem_pthread.dylib         0x00000001823a9760 _pthread_body + 0
    6   libsystem_pthread.dylib         0x00000001823a6d94 thread_start + 4

    Thread 6 name:  com.apple.uikit.eventfetch-thread
    Thread 6:
    0   libsystem_kernel.dylib          0x00000001822c5188 mach_msg_trap + 8
    1   libsystem_kernel.dylib          0x00000001822c4ff8 mach_msg + 72
    2   CoreFoundation                  0x00000001832c25d0 __CFRunLoopServiceMachPort + 192
    3   CoreFoundation                  0x00000001832c01ec __CFRunLoopRun + 1132
    4   CoreFoundation                  0x00000001831ee2b8 CFRunLoopRunSpecific + 444
    5   Foundation                      0x0000000183d2b26c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 304
    6   Foundation                      0x0000000183d4bdd0 -[NSRunLoop(NSRunLoop) runUntilDate:] + 96
    7   UIKit                           0x0000000189ba9c38 -[UIEventFetcher threadMain] + 136
    8   Foundation                      0x0000000183e28e68 __NSThread__start__ + 1024
    9   libsystem_pthread.dylib         0x00000001823a9850 _pthread_body + 240
    10  libsystem_pthread.dylib         0x00000001823a9760 _pthread_body + 0
    11  libsystem_pthread.dylib         0x00000001823a6d94 thread_start + 4

    Thread 7 name:  Dispatch queue: com.apple.root.default-qos
    Thread 7 Crashed:
    0   libsystem_kernel.dylib          0x00000001822e3014 __pthread_kill + 8
    1   libsystem_pthread.dylib         0x00000001823ab450 pthread_kill + 112
    2   libsystem_c.dylib               0x0000000182257400 abort + 140
    3   twiliotest                      0x0000000100320aa0 mono_handle_native_sigsegv (mini-exceptions.c:2420)
    4   libsystem_platform.dylib        0x00000001823a5348 _sigtramp + 52
    5   libsystem_kernel.dylib          0x00000001822de49c abort_with_payload_wrapper_internal + 100
    6   libsystem_kernel.dylib          0x00000001822de4c8 system_set_sfi_window + 0
    7   TCC                             0x0000000185552328 __TCCAccessRequest_block_invoke_2.80 + 0
    8   TCC                             0x0000000185552224 __CRASHING_DUE_TO_PRIVACY_VIOLATION__ + 0
    9   TCC                             0x0000000185555330 __tccd_send_block_invoke + 348
    10  libxpc.dylib                    0x00000001823e6fcc _xpc_connection_reply_callout + 80
    11  libxpc.dylib                    0x00000001823e6f3c _xpc_connection_call_reply + 40
    12  libdispatch.dylib               0x000000018219e1bc _dispatch_client_callout + 16
    13  libdispatch.dylib               0x00000001821aca4c _dispatch_queue_override_invoke + 732
    14  libdispatch.dylib               0x00000001821ae34c _dispatch_root_queue_drain + 572
    15  libdispatch.dylib               0x00000001821ae0ac _dispatch_worker_thread3 + 124
    16  libsystem_pthread.dylib         0x00000001823a72a0 _pthread_wqthread + 1288
    17  libsystem_pthread.dylib         0x00000001823a6d8c start_wqthread + 4

    Thread 8 name:  com.apple.NSURLConnectionLoader
    Thread 8:
    0   libsystem_kernel.dylib          0x00000001822c5188 mach_msg_trap + 8
    1   libsystem_kernel.dylib          0x00000001822c4ff8 mach_msg + 72
    2   CoreFoundation                  0x00000001832c25d0 __CFRunLoopServiceMachPort + 192
    3   CoreFoundation                  0x00000001832c01ec __CFRunLoopRun + 1132
    4   CoreFoundation                  0x00000001831ee2b8 CFRunLoopRunSpecific + 444
    5   CFNetwork                       0x00000001839f38f0 +[NSURLConnection(Loader) _resourceLoadLoop:] + 336
    6   Foundation                      0x0000000183e28e68 __NSThread__start__ + 1024
    7   libsystem_pthread.dylib         0x00000001823a9850 _pthread_body + 240
    8   libsystem_pthread.dylib         0x00000001823a9760 _pthread_body + 0
    9   libsystem_pthread.dylib         0x00000001823a6d94 thread_start + 4

    Thread 9:
    0   libsystem_kernel.dylib          0x00000001822e3314 __semwait_signal + 8
    1   libsystem_c.dylib               0x000000018220125c nanosleep + 212
    2   libsystem_c.dylib               0x000000018220117c usleep + 64
    3   twiliotest                      0x000000010021b694 twilio_pj_thread_sleep (os_core_unix.c:780)
    4   twiliotest                      0x00000001002902f8 twilio_pj_ioqueue_poll (ioqueue_select.c:862)
    5   twiliotest                      0x000000010028d608 worker_proc (endpoint.c:332)
    6   twiliotest                      0x000000010021b4b0 thread_main (os_core_unix.c:531)
    7   libsystem_pthread.dylib         0x00000001823a9850 _pthread_body + 240
    8   libsystem_pthread.dylib         0x00000001823a9760 _pthread_body + 0
    9   libsystem_pthread.dylib         0x00000001823a6d94 thread_start + 4

    Thread 10:
    0   libsystem_kernel.dylib          0x00000001822e323c __select + 8
    1   twiliotest                      0x000000010024ead4 twilio_pj_sock_select (sock_select.c:110)
    2   twiliotest                      0x0000000100290044 twilio_pj_ioqueue_poll (ioqueue_select.c:882)
    3   twiliotest                      0x000000010027d98c twilio_pjsip_endpt_handle_events2 (sip_endpoint.c:741)
    4   twiliotest                      0x0000000100221f64 twilio_pjsua_handle_events (pjsua_core.c:1837)
    5   twiliotest                      0x0000000100221a98 worker_thread (pjsua_core.c:695)
    6   twiliotest                      0x000000010021b4b0 thread_main (os_core_unix.c:531)
    7   libsystem_pthread.dylib         0x00000001823a9850 _pthread_body + 240
    8   libsystem_pthread.dylib         0x00000001823a9760 _pthread_body + 0
    9   libsystem_pthread.dylib         0x00000001823a6d94 thread_start + 4

    Thread 11 name:  AVAudioSession Notify Thread
    Thread 11:
    0   libsystem_kernel.dylib          0x00000001822c5188 mach_msg_trap + 8
    1   libsystem_kernel.dylib          0x00000001822c4ff8 mach_msg + 72
    2   CoreFoundation                  0x00000001832c25d0 __CFRunLoopServiceMachPort + 192
    3   CoreFoundation                  0x00000001832c01ec __CFRunLoopRun + 1132
    4   CoreFoundation                  0x00000001831ee2b8 CFRunLoopRunSpecific + 444
    5   AVFAudio                        0x000000019ce83d24 GenericRunLoopThread::Entry(void*) + 164
    6   AVFAudio                        0x000000019cea9d9c CAPThread::Entry(CAPThread*) + 84
    7   libsystem_pthread.dylib         0x00000001823a9850 _pthread_body + 240
    8   libsystem_pthread.dylib         0x00000001823a9760 _pthread_body + 0
    9   libsystem_pthread.dylib         0x00000001823a6d94 thread_start + 4

    Thread 12:
    0   libsystem_kernel.dylib          0x00000001822c51dc semaphore_timedwait_trap + 8
    1   libdispatch.dylib               0x00000001821b0770 _dispatch_semaphore_wait_slow + 112
    2   libdispatch.dylib               0x00000001821af808 _dispatch_worker_thread + 268
    3   libsystem_pthread.dylib         0x00000001823a9850 _pthread_body + 240
    4   libsystem_pthread.dylib         0x00000001823a9760 _pthread_body + 0
    5   libsystem_pthread.dylib         0x00000001823a6d94 thread_start + 4

    Thread 13:
    0   libsystem_pthread.dylib         0x00000001823a6d88 start_wqthread + 0

    Thread 7 crashed with ARM Thread State (64-bit):
        x0: 0x0000000000000000   x1: 0x0000000000000000   x2:                 0x0000000000000000   x3: 0x000000015be197a0
        x4: 0x000000000000001b   x5: 0x000000016e359b00   x6: 0x0000000000000034   x7: 0xffffffffffffffec
        x8: 0x000000000c000000   x9: 0x0000000004000000  x10: 0x0000000000003dd5  x11: 0x00000001ab196da3
       x12: 0x00000001ab196da3  x13: 0x0000000000000018  x14: 0x0000000000000001  x15: 0x0000000000000881
       x16: 0x0000000000000148  x17: 0x0000000000000000  x18: 0x0000000000000000  x19: 0x0000000000000006
       x20: 0x000000016e35b000  x21: 0x000000010062d6b7  x22: 0x000000010062d77e  x23: 0xc698a6e613ac0034
       x24: 0x000000016e359ee8  x25: 0x000000010062d731  x26: 0x000000015c8c0e78  x27: 0x0000000000000004
       x28: 0xffffffffffffffff   fp: 0x000000016e359e80   lr: 0x00000001823ab450
        sp: 0x000000016e359e60   pc: 0x00000001822e3014 cpsr: 0x00000000

    Binary Images:
    0x1000fc000 - 0x1006ebfff twiliotest arm64          <24d1aa9aa95d3911b2709a7a36f9a785> /var/containers/Bundle/Application/412D52E2-9ECB-4C01-B984-AB2820FBBFB0/twiliotest.app/twiliotest

0x100898000 - 0x1008c7fff dyld arm64 / usr / lib / dyld

由于空间考虑而删除了剩余内容......

EOF

如果我还需要发布任何其他内容,请告知我们。提前感谢您的帮助。

戴夫

2 个答案:

答案 0 :(得分:0)

请确保您使用的是最新的iOS语音SDK 2.0 https://www.twilio.com/docs/api/voice-sdk/ios。您使用的Xamarin组件可能基于弃用版本(Twilio iOS Client SDK)。新版本是可编程语音iOS SDK,支持iOS 10.

changelog中的详细信息。

答案 1 :(得分:0)

如果缺少必需的权限字符串,则定位到iOS 10+的应用会崩溃。

对于Twilio,它需要访问手机的麦克风,因此您的应用需要询问用户麦克风使用权限。

您可以通过编辑应用的Info.plist文件来执行此操作。在<key>NSMicrophoneUsageDescription</key> <string>My app needs to use the microphone.</string>部分中添加此代码<dict> ... </dict>

有关详细信息,请参阅iOS 10 - Changes in asking permissions of Camera, microphone and Photo Library causing application to crashhttps://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html