-[NSUserActivity interaction]: unrecognized selector sent to instance 解决办法翻译

http://stackoverflow.com/questions/40625700/failed-to-get-voip-phone-information-from-native-phone-recents-by-using-callkit

I integrated CallKit framework to my app, and make an outgoing call.

I can see the outgoing call in native phone recents.

But when I tab the outgoing call and want to get phone info. It crashed.

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSUserActivity interaction]: unrecognized selector sent to instance 0x17d4ab90'  

Here is my code in AppDelegate.m

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler NS_AVAILABLE_IOS(8_0){ INInteraction *interaction = userActivity.interaction;
INStartAudioCallIntent *startAudioCallIntent = (INStartAudioCallIntent *)interaction.intent;
INPerson *contact = startAudioCallIntent.contacts[0];
INPersonHandle *personHandle = contact.personHandle;
NSString *phoneNumber = personHandle.value;
}

I crashed in INInteraction *interaction = userActivity.interaction;

And I checked with interaction info

@property (readonly, nullable, NS_NONATOMIC_IOSONLY) INInteraction *interaction API_AVAILABLE(macosx(10.12), ios(10.0));

Following are my environment

mac: 10.12.1xcode: 8.1iOS: 10.1.1

It doesn't violate the requirement

I search all day but seems no one meet this problem.

Is there anything wrong about code level or have another way to get the phone information?

share edit
 
 
Did you mention NSUserActivityTypes in info.plist? –  RJV Kumar  Nov 16 '16 at 7:21
 
No, I don't add NSUserActivityTypes key in info.plist. Is anykey need to add when using callkit? –  Zenki Wu Nov 16 '16 at 8:10 
 
Did you fix the issue? –  RJV Kumar  Nov 17 '16 at 5:06
 
Thanks for your reply :) NSUserActivityTypes key in info.plist doesn't effect for me. But I finally find the root cause. I don't set intents.framework. I can fixed this with adding intents.framework in Target->Build Phases-> Link Binary with Libraries –  Zenki Wu  Nov 17 '16 at 5:55

2 Answers

enter image description here

I have try add NSUserActivity Types bu it not used, I also Use This method sovle This problem. I can fixed this with adding intents.framework in Target->Build Phases-> Link Binary with Librariesenter image description here

share edit delete flag
 

I hope you missed out NSUserActivityTypes key in info.plist. Below is the key and value to add, based on the intent you are handling,

enter image description here

share edit

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值