我正在尝试在iOS应用和相关网站之间共享凭据,实现一些相当基本/标准的Xamarin.iOS代码。
public void TryGetSharedCredential(Action<Tuple<string, string>> callback)
{
try
{
Security.SecSharedCredential.RequestSharedWebCredential("www.jg.com", "me@jg.com", (accounts, err) =>
{
if (accounts != null && accounts.Any())
{
var email = accounts[0];
var password = accounts[1];
callback(new Tuple<string, string>(email, password));
}
});
}
catch (Exception ex)
{
//log exception
}
callback(null);
}
但是,RequestSharedWebCredential
与以下日志崩溃(并且从不进入NSAction)。
2017-10-02 16:33:30.083 JGMobileIOS[65076:4639965] -[__NSCFDictionary UTF8String]: unrecognized selector sent to instance 0x608000282f40
2017-10-02 16:33:30.091 JGMobileIOS[65076:4639965] Xamarin.iOS: Received unhandled ObjectiveC exception: NSInvalidArgumentException -[__NSCFDictionary UTF8String]: unrecognized selector sent to instance 0x608000282f40
2017-10-02 16:33:34.363 JGMobileIOS[65076:4640005] critical: Stacktrace:
2017-10-02 16:33:34.364 JGMobileIOS[65076:4640005] critical:
Native stacktrace:
2017-10-02 16:33:34.365 JGMobileIOS[65076:4640005] critical: 0 JGMobileIOS 0x0000000104938004 mono_handle_native_crash + 244
2017-10-02 16:33:34.366 JGMobileIOS[65076:4640005] critical: 1 JGMobileIOS 0x0000000104945970 mono_sigsegv_signal_handler + 288
2017-10-02 16:33:34.366 JGMobileIOS[65076:4640005] critical: 2 libsystem_platform.dylib 0x000000011151db3a _sigtramp + 26
2017-10-02 16:33:34.366 JGMobileIOS[65076:4640005] critical: 3 ??? 0x0000000000000000 0x0 + 0
2017-10-02 16:33:34.366 JGMobileIOS[65076:4640005] critical: 4 JGMobileIOS 0x00000001049988bc mono_debug_symfile_lookup_method + 44
2017-10-02 16:33:34.366 JGMobileIOS[65076:4640005] critical: 5 JGMobileIOS 0x00000001049fc87d lookup_method_func + 61
2017-10-02 16:33:34.367 JGMobileIOS[65076:4640005] critical: 6 JGMobileIOS 0x0000000104ad75bd monoeg_g_hash_table_foreach + 77
2017-10-02 16:33:34.367 JGMobileIOS[65076:4640005] critical: 7 JGMobileIOS 0x00000001049fc2f9 mono_debug_lookup_method_async_debug_info + 105
2017-10-02 16:33:34.367 JGMobileIOS[65076:4640005] critical: 8 JGMobileIOS 0x000000010489bfbb ss_start + 331
2017-10-02 16:33:34.367 JGMobileIOS[65076:4640005] critical: 9 JGMobileIOS 0x0000000104897b16 debugger_thread + 27910
2017-10-02 16:33:34.367 JGMobileIOS[65076:4640005] critical: 10 JGMobileIOS 0x0000000104a4b283 start_wrapper + 675
2017-10-02 16:33:34.367 JGMobileIOS[65076:4640005] critical: 11 libsystem_pthread.dylib 0x000000011152f93b _pthread_body + 180
2017-10-02 16:33:34.368 JGMobileIOS[65076:4640005] critical: 12 libsystem_pthread.dylib 0x000000011152f887 _pthread_body + 0
2017-10-02 16:33:34.368 JGMobileIOS[65076:4640005] critical: 13 libsystem_pthread.dylib 0x000000011152f08d thread_start + 13
2017-10-02 16:33:34.368 JGMobileIOS[65076:4640005] critical:
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
我试过了:
我已检查了entitlements.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:www.jg.com</string>
<string>webcredentials:www.jg.com</string>
</array>
</dict>
</plist>
我有正确的json:www.jg.com/.well-known/apple-app-site-association(在https上)
{
"applinks": {
//applink stuff
},
"webcredentials": {
"apps": [
//full teamid + appid
]
}
}
我相信下面的Xamarin下面出现了问题 - &gt; iOS api方法映射:
public static void AddSharedWebCredential (string domainName, string account, string password, Action<NSError> handler);
public static string CreateSharedWebCredentialPassword ();
public static void RequestSharedWebCredential (string domainName, string account, Action<string[], NSError> handler);
[Introduced (PlatformName.iOS, 8, 0, PlatformArchitecture.None, null)]
[DllImport ("/System/Library/Frameworks/Security.framework/Security")]
private static extern void SecAddSharedWebCredential (IntPtr fqdn, IntPtr account, IntPtr password, IntPtr completionHandler);
[Introduced (PlatformName.iOS, 8, 0, PlatformArchitecture.None, null)]
[DllImport ("/System/Library/Frameworks/Security.framework/Security")]
private static extern IntPtr SecCreateSharedWebCredentialPassword ();
[Introduced (PlatformName.iOS, 8, 0, PlatformArchitecture.None, null)]
[DllImport ("/System/Library/Frameworks/Security.framework/Security")]
private static extern void SecRequestSharedWebCredential (IntPtr fqdn, IntPtr account, IntPtr completionHandler);
如何获得有关出错的更多细节?我错过了什么和/或我还能尝试什么?
答案 0 :(得分:0)
在与Xamarin支持工程师合作之后,结果证明这是Xamarin.iOS中的一个错误,并将在以后的版本中修复:
https://bugzilla.xamarin.com/show_bug.cgi?id=60423
在此处修复:https://github.com/xamarin/xamarin-macios/commit/03b9d1759e0bafe5d94d319e5a58f798a3ce575b