带有电话的本地通知 [英] Local notification with phone call

查看:39
本文介绍了带有电话的本地通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何继续检测电话是否处于活动状态,无论该应用程序是在后台还是在前台,这样当有人打来电话时,我可以向用户发送本地通知吗?

How can I keep detecting if a phone call is active whether the app is on background or in front so that I can send a local notification to the user when someone calls?

我使用此代码来检测电话是否处于活动状态

I use this code to detect if a phone call is active

#import <CoreTelephony/CTCallCenter.h>
CTCallCenter * callCenter = [[CTCallCenter alloc] init];
    if([callCenter currentCalls] ) {
        NSLog(@"phone call");
    }

我使用设备来测试该应用.

I use a device to test the app.

推荐答案

当应用程序在前台运行时,您可以使用

When the app is running in the foreground, you can detect an incoming call with the Core Telephony Framework.

要在后台检测呼叫,可以使用

To detect calls while in background, you can use CTCallCenter if your app falls into any of these categories provided by Apple:

  • 在后台播放用户可听内容的应用,例如音乐播放器应用程序
  • 在后台录制音频内容的应用
  • 始终让用户了解其位置的应用程序,例如作为导航应用
  • 支持互联网协议语音(VoIP)的应用
  • 需要定期下载和处理新内容的应用
  • 从外部附件接收定期更新的应用

这篇关于带有电话的本地通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆