Uber SSO Login error Swift 2.3 - swift

I'm trying integrate Uber into my app
Use this code to add uber login button:
uberScopes = [.History, .Profile, .HistoryLite, .Places, .RideWidgets, .AllTrips, .Request, .RequestReceipt]
uberLoginManager = LoginManager(loginType: .Native)
let loginButton = LoginButton(frame: CGRectZero, scopes: uberScopes!, loginManager: uberLoginManager)
loginButton.presentingViewController = self
loginButton.delegate = self
loginButton.frame = logoutBgView.bounds
loginButton.autoresizingMask =
[.FlexibleWidth, .FlexibleHeight]
logoutBgView.addSubview(loginButton)
and delegate
func loginButton(button: LoginButton, didLogoutWithSuccess success: Bool) {
if success {
showMessage("Logout")
}
}
func loginButton(button: LoginButton, didCompleteLoginWithToken accessToken: AccessToken?, error: NSError?) {
if let _ = accessToken {
showMessage("Saved access token!")
} else if let error = error {
showMessage(error.localizedDescription)
} else {
showMessage("Error")
}
}
Code not working for native type login in app. When i tap on "Sign in" redirect to safari then app store (i have uber app installed) and not go to uber app to allow or deny scopes that i need. I was set redirect URI, client ID, display name, server token.
Someone can help me?
EDIT1: Log error:
2016-12-28 17:47:40.383 RexpenseSandbox[40681:530203] -canOpenURL:
failed for URL: "uberauth://connect?third_party_app_name=xxxxxxxxxx
&callback_uri_string=xxxxxxxxxxxxxxx&client_id=kEA5TjaXpT7QeicsvWLIYS-L3eWBpVZq&login_type=default&scope=history%20profile%20history_lite%20places%20ride_widgets%20all_trips%20request%20request_receipt&sdk=ios&sdk_version=0.6.0"
- error: "(null)"
EDIT2 - I'm testing a build at Testflight. When i tap on sign in button open uber but isn't appear OAuth only open safari with RedirectURI

Based on that error, it looks like you didn't add the necessary url schemes to your info.plist's Application Query Schemes. Make sure you have the following in your info.plist:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>uber</string>
<string>uberauth</string>
</array>
You can read the tutorial for configuring the SDK for some more info

Related

Dynamic Links not working iOS 15.1 Facebook Swift

Firebase Dynamic Links not working iOS 15.1 for Facebook but working perfectly iOS 14.1. I have tried lot of changes with Dynamic Link parameters. I have checked all parameter configured correctly in the Firebase account and Dynamic link like App BundleId, AppStoreID, AppID and all others parameters.
For iOS 14.1
User post a dynamic link on facebook as a post. When user click on then facebook post redirect to automatically in the app.
For iOS 15.1
User post a dynamic link on facebook as post. When user click on facebook post, the user redirect default Website which i set in the dynamic link url.
User post a dynamic link on facebook as post. When user click on facebook post, the user redirect default Website which i set in the dynamic link url.
Code:-
func createLinkShare1(dynamicLinksDomainURIPrefix:String,link:URL) {
let appBundleID = AppInformation.AppBundleId
if let linkBuilder = DynamicLinkComponents(link: link, domainURIPrefix: dynamicLinksDomainURIPrefix) {
linkBuilder.navigationInfoParameters = DynamicLinkNavigationInfoParameters()
linkBuilder.navigationInfoParameters?.isForcedRedirectEnabled = true
linkBuilder.iOSParameters = DynamicLinkIOSParameters(bundleID: appBundleID)
linkBuilder.iOSParameters?.appStoreID = AppInformation.AppStoreId
linkBuilder.iOSParameters?.minimumAppVersion = AppInformation.AppMinimumVersion
linkBuilder.androidParameters = DynamicLinkAndroidParameters(packageName: appBundleID)
linkBuilder.androidParameters?.minimumVersion = 0
linkBuilder.socialMetaTagParameters = DynamicLinkSocialMetaTagParameters()
linkBuilder.socialMetaTagParameters!.title = "Testing "
linkBuilder.socialMetaTagParameters!.descriptionText = "Invite You"
guard let longDynamicLink = linkBuilder.url else {
print("ERROR in linkBuilder")
return
}
DynamicLinkComponents.shortenURL(longDynamicLink, options: nil) { url, warnings, error in
if let error = error {
print("error shortening link: \(error.localizedDescription)")
return
}
if let url = url {
print("Share Url = ",url)
return
}
}
}
}
Firebase Dynamic Links not working Every Time Open Custom WebView (Redirection issue) Swift
Please check above code and let me know if i'm doing wrong anything, please correct me.
Can someone please explain to me how to show popup or deep working as expected in the Facebook case in the iOS 15., I've tried to with above code but no results yet.
Any help would be greatly appreciated.
Thanks in advance.

Logout sinch user in iOS

I'm working on call/video application. I'm using SINCH SDK and i successfully integrated in swift project and call video work fine but i have a problem that when user is logged out from application still received a notification, i don't know why i used this function to logout
func logOutSinchUser() {
if let client = self._client {
client.stopListeningOnActiveConnection()
client.terminate()
client.unregisterPushNotificationData()
}
self._client = nil
}
Anyone can help me please ?
Please try to unregister the push token first(unregisterPushNotificationDeviceToken if you use sinch managed push) before you terminate the sinch client.
Also use terminateGracefully instead, to give the SDK more time to handle the unregistration process before shut off.
Could be sth like:
func logOutSinchUser() {
if let client = self._client {
client.stopListeningOnActiveConnection()
client.unregisterPushNotificationDeviceToken()
client.terminateGracefully()
}
self._client = nil
}

iOS 10 app crashes when trying to save image to photo library

I'm trying to save an image to the photo library in Swift 3 (I'm working with Xcode 8).
ViewController Code:
func shareImage(image: UIImage) {
let items = [image]
var activityVC: UIActivityViewController = UIActivityViewController(activityItems: items, applicationActivities: nil)
let excludeActivities: [UIActivityType] = [UIActivityType.airDrop,
UIActivityType.assignToContact,
UIActivityType.addToReadingList,
UIActivityType.copyToPasteboard]
activityVC.excludedActivityTypes = excludeActivities
self.present(activityVC, animated: true, completion: nil)
}
When I run the application, and click on the button to take the screenshot (converting it to image, ..., that's all working perfectly), the app asks for permission to access the photo library, I tap the "OK" button, and then the app crashes. The image is not saved in the photo library.
The only clue I get from Xcode is the following:
2016-09-28 11:24:27.216043 Ajax Kids[4143:1545362] [error] error: -addPersistentStoreWithType:SQLite configuration:(null) URL:file:///var/mobile/Media/PhotoData/Photos.sqlite?readonly_shm=1 options:{
NSPersistentStoreFileProtectionKey = NSFileProtectionCompleteUntilFirstUserAuthentication;
NSReadOnlyPersistentStoreOption = 1;
NSSQLitePersistWALOption = 1;
NSSQLitePragmasOption = {
"journal_mode" = WAL;
};
} ... returned error Error Domain=NSCocoaErrorDomain Code=256 "The file couldn’t be opened." UserInfo={reason=Failed to access file: 1} with userInfo dictionary {
reason = "Failed to access file: 1";
}
2016-09-28 11:24:27.216433 Ajax Kids[4143:1545362] [Migration] Unexpected error opening persistent store <private>, cannot attempt migration <private>)
2016-09-28 11:24:27.216568 Ajax Kids[4143:1545362] [Migration] Failed to open store <private>. Requires update via assetsd (256: <private>)
Does anyone have any idea how to fix this?
Thanks in advance!
UPDATE
Sharing the image on Social Media works fine, so the problem is specified to saving the image in the photo library.
Add new records in your new InfoPlist.strings file.
<key>NSPhotoLibraryAddUsageDescription</key>
<string>$(PRODUCT_NAME)</string>
UPD: iOS 11 key
On iOS 11, there is a new property called NSPhotoLibraryAddUsageDescription, similar to NSPhotoLibraryUsageDescription. See https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html
Try to force request permissions like this:
PHPhotoLibrary.requestAuthorization { status in
if status == .authorized {
//do things
}
}
do not forget import Photos. Hope this helps.
I found the culprit in my particular case. We are using Leanplum for analytics and push notifications. The Leanplum.syncResourcesAsync method was causing the opening of the photo library to crash. It took a couple of days to find as I wasn't aware Leanplum was doing anything to hook into a user's photo library... which in itself is concerning.
We weren't using the functionality this particular method brings, so were able to just remove the method call and the photo library stopped crashing.

FIrebase Google auth operation not supported in this environment

I am working on ionic and firebase project, made a login page to sign in with google. I am using this Below.
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithRedirect(provider).then(function (result) {
var token = result.credential.accessToken;
// The signed-in user info.
var user = result.user;
$state.go('app.homepage');
}).catch(function (error) {
});
firebase.auth().getRedirectResult().then(function (result) {
if (result.credential) {
var token = result.credential.accessToken;
}
// The signed-in user info.
var user = result.user;
}).catch(function (error) {
});
When I run it in the browser it is working fine, but when I run it in android device I am getting auth/operation-not-supported-in-this environment.
The application is running on "location.protocol".
I researched a bit but could not find an exact answer. What could be wrong ?
popup and redirect operations are not currently supported in Ionic/Cordova environment. As a a fallback you can you an oauth cordova plugin to obtain a google/facebook OAuth access token and then sign in the user via signInWithCredential. Check this thread for more on this:
auth.signInWithCredential(firebase.auth.FacebookAuthProvider.credential(fbAccessToken));
https://groups.google.com/forum/#!searchin/firebase-talk/facebook$20cordova/firebase-talk/mC_MlLNCWnI/DqN_8AuCBQAJ
Try the following because local storage is not enabled in webView, which is required for firebase
webSettings.setDomStorageEnabled(true);

Facebook api with Xamarin

I am creating an application by Xamarin (andoroid / iOS) and would log in using facebook, and I do so by sharing the same access code?
You can do it by following the code sample I've published here: https://github.com/IdoTene/XamarinFormsNativeFacebook
a guide of how to do so:
Steps to set up your project:
Installation:
1) For Android download from nuget/Components the Facebook Android SDK: http://components.xamarin.com/view/facebookandroid and place it in your droid project.
2) For iOS download from nuget/Components the Facebook iOS SDK: http://components.xamarin.com/view/facebookios and place it in your iOS project.
Set up components:
Shared code set up:
1) Add a FacebookLoginButton which inherits from Button, leave it without any implementation
2) Add that button to the login page
3)Add to App.cs the following property:
public static Action<string> PostSuccessFacebookAction { get; set; }
4) in the LoginPage.xaml.cs (or in the viewmodel class if you have one), add the navigation for this action:
App.PostSuccessFacebookAction = async token =>
{
//you can use this token to authenticate to the server here
//call your FacebookLoginService.LoginToServer(token)
//I'll just navigate to a screen that displays the token:
await Navigation.PushAsync(new DiplayTokenPage(token));
};
Android: 1) Add to strings.xml file (found at Resources/Valus) The following lines {Your App Id Here} {Your App Name}
2) Add to Manifest.xml the following code:
3) Create activity class for facebook (I called it FacebookActivity)
4) Create a custom rendrer for the facebook Login button (I called it FacebookLoginButtonRendererAndroid)
5) Add to mainActivity class The OnActionResult method to handle response from the FacebookActivity
iPhone:
1) In AppDelegate class, register in method FinishedLaunching the following:
FBSettings.DefaultAppID = FacebookAppId;
FBSettings.DefaultDisplayName = FacebookAppName;
2) Override the following methods:
public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
{
base.OpenUrl(application, url, sourceApplication, annotation);
return FBSession.ActiveSession.HandleOpenURL(url);
}
public override void OnActivated(UIApplication application)
{
base.OnActivated(application);
// We need to properly handle activation of the application with regards to SSO
// (e.g., returning from iOS 6.0 authorization dialog or from fast app switching).
FBSession.ActiveSession.HandleDidBecomeActive();
}
3) Create a custom rendrer for the facebook Login button (I called it FacebookLoginButtonRendererIos)