How we can invoke the portsip delegate if app is terminated or force quite - ios10

I am using portsip SDK (trial version) in my application for VOIP call. Call is working fine in foreground and background as well. I m using Call Kit framework for incoming/outgoing call at client side, When i removed application from background or force quite the app, in that case when i try to call with other device call is coming, i received VOIP push but port sip incoming delegate does not invoke whereas if i call again (2nd time in same app state) port sip incoming delegate invoke. so until incoming delegate does not call we can not accept.decline incoming call.**
So please help me out how we can invoke the port sip delegate if app is terminated or force quite.

I had a similar problem on my side but I am not using portsip. So If it is related with portsip my answer may not be correct however I followed some steps on the Apple Example. When I added configureAudioSession() method everything worked fine for me. For example:
func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
// Create & configure an instance of SpeakerboxCall, the app's
configureAudioSession()
self.provider.reportOutgoingCall(with: call.uuid!, connectedAt: Date())
action.fulfill()
}
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
// Retrieve the SpeakerboxCall instance corresponding to the action's call UUID
guard callManager.callWithUUID(uuid: action.callUUID) != nil else {
action.fail()
return
}
configureAudioSession()
// Signal to the system that the action has been successfully performed.
action.fulfill()
}
Hope it helps.

Related

iOS. How to know if faceid prompt is presented?

Is there any way (in swift) to know if the system faceId prompt is being presented? I can't see any event, notification or delegate method. I should avoid the presentation of a view triggered by an asynchronous event in case the app is trying to authenticate the user.
There is no specific event, notification, or delegate method in Swift that allows you to determine if the system Face ID prompt is being presented. However, you can use the LAContext class to check the availability and state of Face ID on the device, and then use that information to determine if the prompt is likely to be displayed.
You can use the canEvaluatePolicy method of LAContext to check if the device supports Face ID and if the user has configured it.
let context = LAContext()
var error: NSError?
if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
//FaceID is available
}
Then you can use the evaluatePolicy method to check if the user already authenticated recently or not.
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: "Log in with Face ID") { success, error in
if success {
// Face ID authentication was successful
} else {
// Face ID authentication failed
}
}
It's important to notice that you should avoid presenting a view triggered by an asynchronous event in case the app is trying to authenticate the user.

CallKit :- Callkit is working but the callee doesn't get the call

I want to develop an SOS application. When I am trying to use URL schema openURL(), it will display an alert but my requirement is to connect the call without any alert or popup while trying to call. So I found a solution using CallKit. When I implemented CallKit in my application it does not ask for any permission, the outgoing call is placed but the callee doesn't get any call. Is there any solution for this?
I have tried the following code for connecting the call.
#IBAction func buttonCallTapped(_ sender: Any) {
let provider = CXProvider(configuration: CXProviderConfiguration(localizedName: "My App"))
provider.setDelegate(self, queue: nil)
let controller = CXCallController()
let transaction = CXTransaction(action: CXStartCallAction(call: UUID(), handle: CXHandle(type: .phoneNumber, value: "\(number)")))
controller.request(transaction, completion: { error in })
DispatchQueue.main.asyncAfter(wallDeadline: DispatchWallTime.now() + 5) {
provider.reportOutgoingCall(with: controller.callObserver.calls[0].uuid, connectedAt: nil)
}
}
You just can't make standard native calls through CallKit. The CallKit framework, as clearly stated in the documentation, is meant to be used to develop custom VoIP applications and integrate them with the native phone interface.
Any iOS application can't make native call without user action.
An alert will be shown with phone number and two buttons will be available "Call" and "Cancel" which is presented from the OS level.
Just like we are showing popup to delete photos from Photos app.
Solution
If you want to implement SOS Application (Yes its possible using VoIP
service), But you can place calls when app is active (Can be done
without user action given internet connection is there.)
Note: The receiving side also should support VoIP.
How to Implement VoIP
We need permission of Voice over IP services to make calls in between iPhone devices.
VoIP app must have background mode enabled in the Xcode Project >
Capabilities pane. Select the checkbox for Voice over IP
Also CallKit is indented only for VoIP Apps, If you really want to implement the VoIP follow CallKit Tutorial

Firebase Connectivity Test Shows Disconnected At Start Even When Connected. How Do I Change This?

I am trying to make sure Firebase has a connection before continuing to load the app. I'm using the code from Firebase's own code sample. I have placed it in the ViewDidLoad function on my home view controller:
let connectedRef = Database.database().reference(withPath: ".info/connected")
connectedRef.observe(.value, with: { snapshot in
if let connected = snapshot.value as? Bool, connected {
print("Connected")
} else {
print("Not connected")
// show alert here
}
})
The problem is that the above code always shows "Not Connected" before then showing "Connected". This is a problem because when the app is not connected, it's supposed to show an alert, and the alert will then fire every time the user opens the app.
Is this expected behavior? If so, is there a way around it?
How do I check for Firebase connectivity without Firebase returning that it's not connected first every time?
The behavior you're observing is expected. The Firebase SDK can't establish its connection immediately upon startup. There is always going to be some latency between launch and whenever a connection is first available.
Also, I don't think this strategy is a good idea, because mobile connections can be intermittent and flakey. Firebase can not possibly ensure that your app will retain a good connection even after it's first established. Your app will be easier to use if you assume that it doesn't have a connection all the time. Users have come to expect some level of offline usage, and Realtime Database supports that to some degree with offline data persistence.

Sinch: user does not receive the call for the first time

I implemented Sinch + PushKit + CallKit, everything works fine, but there is one script that does not work correctly. The first user uses the application and removes it from the device's memory, the second user calls for the first time, the first user does not receive the call, if the second user immediately calls the second time, the first user receives a call (later the first user also receives a call). If the first user opens the application (that is, becomes online for the system), the first user will not receive the call again. How can I fix it?
initialization of the sinch client
open func setup() {
guard sinch == nil else { return }
guard let userID = UserRealmManager().getUser()?.id else { return }
sinch = Sinch.client(withApplicationKey: key, applicationSecret: secret, environmentHost: host, userId: userID)
sinch?.delegate = self
sinch?.call().delegate = self
sinch?.setSupportCalling(true)
sinch?.enableManagedPushNotifications()
sinch?.setSupportPushNotifications(true)
sinch?.start()
sinch?.startListeningOnActiveConnection()
}
Update: I also found that if I restart the iPhone then calls through CallKit start to show up in 2-4 minutes, I decided to test it on the famous messangers such as What's app and Telegram and they have exactly the same behavior. Of course, I think it needs to be asked as an additional question.
My devices are iPhone 6 and 7.
This was my mistake, since I initialized SinchManager (this is the manager that manages SINClient) only in MainTabBarController viewDidLoad(), after I began to initialize it in AppDelegate didFinishLaunchingWithOptions, everything works fine.

APNS notification does not work when app is not running or background

I'm using pyapns to send notification to iPhone.
receiving notification when the app is running was success.
but, when app is not running or app is on background, it can't receive notification.
is it related with URL identifier or scheme? if not, what is the problem..?
Did you get called in
- (void)application:didReceiveRemoteNotification:
while you were in the app?
the problem from notification msg.
among the notify function args, there is notifications list arg.
note that, when you make this parameter, a dictionary of this list should contain below. so that the application can do alert reaction.
thePayLoad = {
'aps': {
'alert':'this option should be contained if you want to see the alert msg',
'sound':'k1DiveAlarm.caf',
'badge':42
},
'test_data': { 'foo': 'bar' }
}
In my case, I just sent msg not containing above. and in didReceiveRemoteNotification function, I made alert msg. but msg not containing alert information. so the device couldn't react.