我与iPhone:当手机接到电话并回到应用程序时,应用程序可以检测到吗?
- (void)applicationWillEnterForeground:(UIApplication *)application
当谈到回应用程序检查它。
但是这个不检测用户何时拒绝呼叫。无论如何,即使用户拒绝接听电话时也能检测到吗?
我与iPhone:当手机接到电话并回到应用程序时,应用程序可以检测到吗?
- (void)applicationWillEnterForeground:(UIApplication *)application
当谈到回应用程序检查它。
但是这个不检测用户何时拒绝呼叫。无论如何,即使用户拒绝接听电话时也能检测到吗?
我不知道告诉何时拒绝来电。但这种方法被调用,当用户收到电话:
- (void)applicationWillResignActive:(UIApplication *)application {
}
也许你可以使用下面的通知,你的情况,第二个:
添加CoreTelephony.framework
到您的项目和:
#import <CoreTelephony/CTCall.h>
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callReceived:) name:CTCallStateIncoming object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callEnded:) name:CTCallStateDisconnected object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callConnected:) name:CTCallStateConnected object:nil];
我想你想要的是检测应用何时回到活动状态。 有两种代表方法:
applicationWillEnterForeground: 告诉代理应用程序即将进入前台。
- (void)applicationWillEnterForeground:(UIApplication *)application
和
applicationDidBecomeActive: 告诉应用程序已成为活跃的代表。在documentation of UIApplicationDelegate
- (void)applicationDidBecomeActive:(UIApplication *)application
更多信息