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)
}
Related
Is it possible to access calendar events in screen saver? I am able to request permission in the application. But some API is not prompting in the case of the screensaver.
I didn't find any documentation around it.
I used the following code to requesting calendar events:
func requestPermissionForCalendar()
{
var eventStore = EKEventStore()
eventStore.requestAccess(to: EKEntityType.event) { granted, error in
if granted{
print("Permission granted")
}else{
print("The app is not permitted to access reminders, make sure to grant permission in the settings and try again")
}
}
}
Couple of things, first, a screen saver is completely passive in macOS. Any prompt for anything will be disregarded when it's running fullscreen, as a screensaver.
In general, the proper way to do this with a screensaver is to ask for permission in the configurationSheet (the screen saver options). The user will get prompted there, and can allow or deny you. I do use this for example to request the user location.
Once allowed in System Preferences, your screensaver when running in screensaver mode will get access. I suggest you test your code first in the configuration sheet as this is much easier.
Additional note, ScreenSavers on macOS since Catalina are sandboxed by an application extension provided by Apple, and that extension has a limited list of entitlements (see a list here https://github.com/glouel/ScreenSaverMinimal).
I'm not particularly familiar with EKEventStore, but if it requires a specific entitlement to make it work, you'll be stuck as you can't add any entitlement yourself, everything depends on legacyScreenSaver.appex.
I'm trying to authenticate with Uber's API using watchOS 6.2's new OAuth capability ASWebAuthenticationSession:
ASWebAuthenticationSession(url: uberUrl, callbackURLScheme: scheme) { (URL?, Error?) -> in {
print(callbackUrl, error)
if let url = callbackUrl {
let components = NSURLComponents(string: (url.absoluteString))
if let t = components?.queryItems?.filter({$0.name == "code"}).first?.value {
self.token = t
}
}
}
When I run it, an adorable little web browser comes up on the Watch and prompts for a "E-mail or Mobile Number", after entering my e-mail, clicking on "Next" pops up a text entry window which then suddenly disappears, leaving me back at e-mail entry. The subsequent clicks on "Next" brings up a text entry window which only allows me to edit the e-mail address. Password is never an option. I never got the closure to complete, not even with en error.
If I scroll down to "Login with Google", then Google's login page loads, and lets me enter e-mail and password, and the completion block executes (I get a nil token presumably because my Uber account is not a Google one).
I suspect an issue with Uber's login webpage, but can't verify that other than observing that Google's seems to work. Also, I can find no documentation on the callbackURLScheme parameter with respect to watchOS. I create a scheme in the plist as one might with an iOS app, but can't confirm this is the correct procedure. Nonetheless, it doesn't change the fact that the password field will not come up on Uber's oath login page.
Searching StackOverflow for watchOS and ASWebAuthenticationSession produces no results at this point.
Is anyone else trying to do this right now? Has anyone had success? Am I missing something important, or is this simply an error on Uber's part?
My app only needs the 'Privacy - Photo Library Additions Usage Description' property in the plist file (app writes to Photo library, but doesn't read).
I use this code to check for permissions:
PHPhotoLibrary.requestAuthorization { status in
if status == .authorized {
print("Permission granted")
} else {
print("Unavailable")
}
}
In the iOS Settings for my app, even though the plist only needs 'Add Photos Only', 'Read and Write' is also listed (??), and the above code only gets the authorised status if 'Read and Write' is ticked (ticking 'Add Photos Only' just causes the above code to go through to the else statement).
I'm a bit confused to why 'Read & Write' is even listed as a setting for my app, when my plist doesn't include "Privacy - Photo Library Usage Description".
Any ideas?
It's because you are calling PHPhotoLibrary.requestAuthorization.
If all you need is to write blindly into the user's camera roll, do not call PHPhotoLibrary.requestAuthorization. Just go ahead and write, e.g. by calling UIImageWriteToSavedPhotosAlbum or UISaveVideoAtPathToSavedPhotosAlbum. The runtime will request authorization on your behalf.
But if you want to interact with the photo library itself, i.e. thru the Photos framework, then you need authorization and an entry under Privacy - Photo Library Usage Description, even if all you intend to do is write.
Judging by your comments, you may be confused about what requestAuthorization does. It tries to obtain permission. If all you want to know is what the current authorization status actually is, call authorizationStatus instead.
However, even then, we're talking about the photo library itself, and thus the value referred to as Read & Write in Settings.
If you want to know whether you have permission to do UIImageWriteToSavedPhotosAlbum or UISaveVideoAtPathToSavedPhotosAlbum, just go ahead and call it. If there's a permissions problem, you'll hear about it in the completion handler.
I'm trying to implement Firebase Dynamic Linking.
i have created project on firebase console and provided the required
value(prefx and appid).
i also have allowed the association domains from developer console
and it is sucessfully showing true flag.
in xcode i have on the feature of association domain and added the url identifiers etc.
Problem: still the problem i'm facing is that Association Domain Section says
Add the Association Domains feature to your App ID.
don't know whats the reason why i'm getting this error.
The screen shot is also attached for prove.
i have figured this out by searching for long time.
This is basically not a big issues the error
“Add the associated Domains feature to your App ID”
Will go away once you enable the Associated Domains in your APP ID in developer.apple.com. If it doesn’t go away, quit and relaunch the xcode few times and it will work.
reference: https://medium.com/#abhimuralidharan/universal-links-in-ios-79c4ee038272
I had a similar problem. The problem was solved when I turned off and turned on the feature in Capabilities. But then I had several entitlements files in different folders. Steps to combine these files into one:
Open in text editor MY_PROJECT_NAME.xcodeproj\project.pbxproj
Find CODE_SIGN_ENTITLEMENTS and set correct path. Example:
"MY_PROJECT_NAME/Entitlements/MY_TARGET_NAME.entitlements"
I do not recommend using a standard text editor, since it can automatically replace some characters in the file while saving.
You need to add Associated domains to your App Capabilities. Please see screenshot. Add applinks:yourdomain.com
Then Use below code to get Short URL
guard let link = URL(string: "https://www.yourdomain.com/share_location.html?Id=\(RandomID)&uid=\(uid)") else { return }
let dynamicLinksDomain = "yourdomain.page.link"
let components = DynamicLinkComponents(link: link, domain: dynamicLinksDomain)
// [START shortLinkOptions]
let options = DynamicLinkComponentsOptions()
options.pathLength = .unguessable
components.options = options
// [END shortLinkOptions]
// [START shortenLink]
components.shorten { (shortURL, warnings, error) in
// Handle shortURL.
if let error = error {
print(error.localizedDescription)
return
}
print(shortURL?.absoluteString ?? "")
}
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/