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

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

Related

Swift how to set manually photoLibrary and camera authorization?

When using my app, the user is asked permission to access camera and library one time (when needed), answering allow or not in the "apple alert" (requestAccess).
I need to add a view where the user can be able to change these authorizations afterwards if he wants. I added switch buttons so the user can make the choice to keep it authorized or not. But I can't find how to set the authorizationStatus.
Is there a way to change the authorizationStatus manually, from .authorized to .denied or opposite ?
I tried to prompt the apple alert using 'AVCaptureDevice.requestAccess()' but it doesn't show if the user already authorized before.
Any suggestion welcome :)
By security and privacy reasons developers have only one way - use system dialog for requesting authorization for access to protected system services.
But you can suggest for your users a short way to system settings. This code launches the Settings app and displays your app’s custom settings.
let settingUrl = URL(string: UIApplication.openSettingsURLString)
DispatchQueue.main.async {
UIApplication.shared.open(settingUrl!, options: [:], completionHandler: nil)
}

How do we find the list of VOIP URLschemes registered in the device?

I DO NOT want to use the following:
if let url = URL( string: "tel://4151231234" )
{
UIApplication.shared.open( url, options: [:] )
}
Instead, I would like to have a list of supported URLschemes in the device that allows making phone calls. Something that would result in a list a bit like the following:
"tel://", "whatsapp://", "facetime://", "Hangout://", etc.
The problem using the "tel://" URL scheme is that iOS returns
iPhone Calls Not Available" on all devices that are not paired
with an iPhone even though they have VOIP apps that supports phone calls.
I do not want to become a VOIP app myself (using CallKit).
But I do not mind using using CallKit IF I don't implement
the entire API to become a phone app.
The Contact App has the behavior that I am looking for:
- When Selecting a contact (in the Apple's contact app),
Tap on "Call" at the top
- A pop up list of applications supporting phone calls is listed
including 'Call', "Facetime" and "Hangouts" (in my iPad).
I would like to have the list that allows the Contact app to know which apps (and also which URLschemes) can be used to make phone calls.
I bet it is simple... I just don't know ;( Help me please :<
I DO NOT want to use the following:
if let url = URL( string: "tel://4151231234" )
{ UIApplication.shared.open( url, options: [:] )
}
What would be the code to create a list of apps/URLscheme that support making phone calls?

MAC application deactivate when minimise or is in background

I am developing a mac application in which I am showing some count on app icon symbol (Similar to notification count). It work fine when app is in foreground and is active. But as an when I minimise the app or app goes into background. I am not able to see any message count on icon symbol.
let app = NSApplication.sharedApplication()
app.dockTile.showsApplicationBadge = true
app.dockTile.badgeLabel = String(unrdcount)
This method is called when I am getting data from a particular API. Can anyone suggest me how to let a particular API work for infinite time, so that if the application is ON user can get this unrdcount from API.

ios app rejected on using AWS cognito implementation from mobile hub

We recently got our ios app rejected because of the following:
We noticed that the user is taken to Safari to sign in or register for an account, which provides a poor user experience.
however, the bit that launches the safari window for facebook/Google login is part of the AWSMobileHubHelper framework so we can't modify that code.
Any ideas/solutions would be greatly appreciated.
So I found a workaround. I just grab the GIDSignIn instance and change the properties myself. In case any one else wants to know how, all you have to do is:
Add a bridge header and import #import <GoogleSignIn/GoogleSignIn.h>
Implement the presentViewController method for GIDSignInUIDelegate on your main login controller
func signIn(signIn: GIDSignIn!, presentViewController viewController: UIViewController!) {
presentViewController(viewController, animated: true, completion: nil)
}
Edit demo login code to be something like this:
func loginWithGoogle(delegate: GIDSignInUIDelegate!) {
let googleProvider = AWSGoogleSignInProvider.sharedInstance()
// It is important that these are initialized after
// AWSGoogleSignInProvider.sharedInstance() is called
GIDSignIn.sharedInstance().uiDelegate = delegate
GIDSignIn.sharedInstance().allowsSignInWithBrowser = false
GIDSignIn.sharedInstance().allowsSignInWithWebView = true
handleLoginWithSignInProvider(googleProvider, callback: callback)
}
As of iOS 9 using Facebook SDK, this is expected behavior per Facebook login. Mobile Hub quickstart app is just applying the Facebook SDK 3 and using the APIs as directed. Check out the brief description below and read through the comments to get a better insight. This was not a popular decision by Facebook and others have provided workarounds (to forcing user authentication via mobile browser) if you wish to experiment. As for the AWSMobileHubHelper framework, we are looking into making this available at some point but don't have a timeline for this.
"Logic that automatically defaults people to the optimum experience for iOS 9. This means that the SDK dialogs for Facebook Login, Sharing across Facebook and Messenger, App Invites, App Events, or Native Like will automatically determine the best experience for people based on their device."
Source:
https://developers.facebook.com/blog/post/2015/09/10/new-SDK-for-iOS9/

What Callback url i need to set in my twitter app page for my iOS App?

I'm trying to implement twitter integration for my iOS app and my apps deployment target is 4.0 & greater, I'm using bengottlieb sample for twitter share, In my twitter app page in Callback URL: text field When I don't set callback url in app settings my app is crashed! (authenticatedWithUsername delegate method is getting called but it is dismissing the view controller)What callback url I must set?I want to return to the app after authorization?
You just have to provide any valid URL at the Settings -> Callback Url.
I have used "https://www.google.com" and my app start working.
Also, remember to unchecked the Enable Ca Callback Locking