问题描述
我想通过airdrop发送一个字符串,我想在其他设备上成功收到String时调用一个函数。我通过UIActivityViewController实现了它,我通过completionHandler检查它。
I want to send one string via airdrop, I want to call one function when the String is received on other device successfully. I had implemented it through UIActivityViewController and I check it via completionHandler.
这是我的场景:
设备A - >发送字符串到设备B
如果设备B接收有两个选项 - >接受或拒绝
我想在设备B收到或拒绝该消息时在设备A上调用一个函数。
Here is my scenario :Device A ->send a string To Device BIf Device B receive have two option -> Accept or DeclineI want to call one function on Device A when Device B will receive or Decline that message.
以下是我的实现:
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[self.customURLContainer] applicationActivities:nil];
activityViewController.completionHandler = ^(NSString *activityType, BOOL completed) {
NSLog(@"completed dialog - activity: %@ - finished flag: %d", activityType, completed);
if ( completed )
{
NSLog(@"completionHandler - Succeed");
}
else
{
NSLog(@"completionHandler - didn't succeed.");
// didn't succeed.
}
但上面的函数总是返回0,字符串是已发送或通过其他设备拒绝。
But the above function always return 0, wether string is "Sent" or "Decline" by the other device.
是否可以检查设备A?因为我们可以看到设备A上的活动(如果收到)而不是已发送,如果拒绝而不是已拒绝。
Is it possible to check the on Device A? Because we can see the activity on Device A if receive than "Sent" and if Decline than "Declined".
推荐答案
不,目前这是不可能的。您应该向Apple提交,但要求
No, this is currently not possible. You should file a bug report with Apple requesting this though
这篇关于UIActivityViewController completionHandler如何检查活动是否成功发送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!