Posts

Post not yet marked as solved
0 Replies
584 Views
Hi Team,We're using VoIP push in our app. In iOS 13 and above it stopped working after some time of usage.I have read multiple threads, documentations and StackOverflow answers but everywhere only one thing is mentioned that It is mandatory to report an incoming call via CallKit if any VoIP push receives, We're doing same. But still, it stopped working after 1-2 days.Below are the cases which we handle:1. VoIP push receives and user is not on callAction: We immediately report an incoming call.2. VoIP push receives and user is on call (Video call screen is opened so we consider he is on call)Action: We immediately report an incoming call. Then later we're canceling this.- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion { if (type == PKPushTypeVoIP) { NSDictionary *dict = [payload dictionaryPayload]; if (dict && dict[@"aps"] && [dict[@"aps"] isKindOfClass:[NSDictionary class]]) { VoipPushPayload *payload = [[VoipPushPayload alloc] initWithDicionary:dict[@"aps"]]; [self reportIncomingCall:payload]; if ([self isCallViewPresented]) { // We will disconnect it immediately NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:payload.callId]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [[self callController] reportEndCallWithReasonWithUuid:uuid reason:CXCallEndedReasonFailed]; }); // Notify Caller that I'm busy via simple push notification FCMPushPlatform platform = ([payload.callerPlatform integerValue] == 1) ? FCMPushPlatformiOS : FCMPushPlatformAndroid; payload.isIncoming = @NO; [[PushHelper sharedInstance] sendFCMPush:payload type:@"busy" toToken:payload.callerDeviceId onPlatform:platform isSilent:YES completion:^(BOOL success) { }]; return; } // Background task to handle the incoming call timeout when app is terminated or in killed state self.incomingBackgroundRejectTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ [[UIApplication sharedApplication] endBackgroundTask: self.incomingBackgroundRejectTask]; self.incomingBackgroundRejectTask = UIBackgroundTaskInvalid; NSLog(@"incoming background task ended"); }]; self.incomingTimer = [NSTimer scheduledTimerWithTimeInterval:30 target:self selector:@selector(incomingCallTimeout:) userInfo:@{@"payload": payload} repeats:NO]; } } completion(); }We're using Twilio Video call sample which is in Swift and our code is in Objective-C. So we're using bridging for this. Here are the body of above functions.- (ViewController *)callController { if (!self.callViewController) { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Twilio" bundle:nil]; self.callViewController = [storyboard instantiateViewControllerWithIdentifier:@"ViewController"]; } return self.callViewController; } - (void)reportIncomingCall:(VoipPushPayload *)payload { // Reporting the incoming call [[self callController] reportIncomingCallWithPayload:payload completion:^(NSError *error) { }]; self.currentPayload = payload; [self callController].enlargeParticipantId = payload.callerId; [[self callController] localPreviewAsFullScreen]; }Swift code is written in ViewController.swift classfunc reportIncomingCall(payload: VoipPushPayload, completion: ((NSError?) -> Void)? = nil) { let uuid = UUID(uuidString: payload.callId)! let callHandle = CXHandle(type: .generic, value: payload.roomName) let callUpdate = CXCallUpdate() callUpdate.remoteHandle = callHandle callUpdate.supportsDTMF = false callUpdate.supportsHolding = true callUpdate.supportsGrouping = false callUpdate.supportsUngrouping = false callUpdate.hasVideo = true callUpdate.localizedCallerName = payload.callerName; callKitProvider.reportNewIncomingCall(with: uuid, update: callUpdate) { error in if error == nil { NSLog("Incoming call successfully reported.") } else { NSLog("Failed to report incoming call successfully: \(String(describing: error?.localizedDescription)).") } completion?(error as NSError?) } } func reportEndCallWithReason(uuid: UUID, reason: CXCallEndedReason) { callKitProvider.reportCall(with: uuid, endedAt: nil, reason: reason) }callKitProvider instance is creating one time per app launch as this is the property of ViewController class and we are initializing ViewController only once.Please help us to find why VoIP push stopped working after some time.Thanks & Regards,Mansoor
Posted Last updated
.