【问题标题】:Validate if call was made after telprompt验证是否在 telprompt 之后进行了调用
【发布时间】:2014-03-11 15:22:38
【问题描述】:

我想验证用户是否在 telprompt 后点击了 Call 按钮或 Cancel 按钮

当前代码:

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@", [personDetails valueForKey:@"phone"]]];
    [[UIApplication  sharedApplication] openURL:url];

我该怎么做?

【问题讨论】:

    标签: iphone objective-c nsurl


    【解决方案1】:

    First telprompt: 不是记录在案的 URL 架构,不应使用。因为苹果可以随时改变它的使用方式。

    其次,由于数据被传回您的应用,您将无法检测到是否进行了调用。您可能能够检测到您是否使用CoreTelephony。但是要让它工作需要你的应用程序在后台运行,你可能不得不为此滥用一些后台模式,这将使 Apple 拒绝你的应用程序。

    您能解释一下为什么要检测是否有来电吗?

    【讨论】:

      【解决方案2】:
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(called:) name:@"UIApplicationSuspendedNotification" object:nil];
      
      -(void)called:(NSNotification *) notification
      {
          NSLog(@"Tapped Call button");
      }
      

      如果点击呼叫按钮,则应用程序将被终止并进入后台,因此只需为UIApplicationSuspendedNotification 通知添加一个观察者。

      【讨论】:

      • 现在不会了。我测试了它,它工作得很好。
      • 我没有说它不起作用,我只是说它不是 100% 的解决方案。因为如果显示对话框并且应用程序被用户推送到后台,那么无论是点击主页按钮还是其他一些应用程序都会进入前台,您也会收到此通知。也不推荐使用telprompt: 方案,因为它不是官方方案。
      【解决方案3】:

      就我而言,我使用了tel:// 而不是telprompt://,并创建了自己的UIAlertView。通过这种方式,您可以检测到是否从UIAlertView 的委托中点击了调用选项。

      【讨论】:

      • 你能分享你的代码吗?因为我认为您不能为 tel:// 添加自己的警报,因为它是系统提供的警报。
      猜你喜欢
      • 2012-12-24
      • 1970-01-01
      • 1970-01-01
      • 2017-04-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-29
      • 2015-06-01
      • 1970-01-01
      相关资源
      最近更新 更多