常见的问题

实时通话,被叫方接收到通知
最后更新 7 年以前

用户A为主叫,B为被叫,使用IM SDK要求版本大于3.2.3
分三种情况:
1.B在线,且App在前台活跃状态
A向B发起通话,B用户通过EMCallManagerDelegate协议的- (void)callDidReceive:(EMCallSession *)aSession回调方法来接收来自A的通话请求,处理UI

2.B在线,且App切入后台,时间短于3分钟左右,此时App没有被系统挂起,长连接处于连接中
首先,在系统生命周期回调
- (void)applicationWillEnterForeground:(UIApplication *)application NS_AVAILABLE_IOS(4_0);
- (void)applicationDidEnterBackground:(UIApplication *)application NS_AVAILABLE_IOS(4_0);
分别添加
[[EMClient sharedClient] applicationDidEnterBackground:application];
[[EMClient sharedClient] applicationWillEnterForeground:application];
可以异步调用

A向B发起通话,B用户通过EMCallManagerDelegate协议的- (void)callDidReceive:(EMCallSession *)aSession回调方法来接收来自A的通话请求。此时App为后台,可以在此回调中先判断[UIApplication sharedApplication].applicationState是否为UIApplicationStateBackground,如果判断成立,自行实现本地通知。

3.B离线,IM SDK长连接已经断开(B端App进程被杀掉,或者B端处于后台时间超过3分钟,被系统挂起)
首先,在系统生命周期回调
- (void)applicationWillEnterForeground:(UIApplication *)application NS_AVAILABLE_IOS(4_0);
- (void)applicationDidEnterBackground:(UIApplication *)application NS_AVAILABLE_IOS(4_0);
分别添加
[[EMClient sharedClient] applicationDidEnterBackground:application];
[[EMClient sharedClient] applicationWillEnterForeground:application];
可以异步调用。
另外,确保App已经可以接收文本消息的APNs推送

A端在发起通话前,需要设置EMCallOptions属性isSendPushIfOffline为YES,遵守EMCallBuilderDelegate协议,并且通过[[EMClient sharedClient].callManager setBuilderDelegate:self]为此协议添加委托实例。
实现协议回调- (void)callRemoteOffline:(NSString *)aRemoteName。

A向B发起通话后,B端长连接已经断开,此时A会执行- (void)callRemoteOffline:(NSString *)aRemoteName,需要在此回调中实现文本消息的发送,接收方为aRemoteName,也就是B的环信id。当B收到APNs推送后,可以点击横幅来唤醒App。之后按照系统App接收APNs推送的流程来处理。

请稍候!

请稍候...它将需要一点时间 !