Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to open another URL of SF after opening login URL on Safari controller #22

Closed
NanostuffsTech opened this issue Jan 27, 2017 · 9 comments
Labels

Comments

@NanostuffsTech
Copy link

Hi,

I'm using swiftly salesforce to for login to salesforce account from my iPhone app using Swift 3.0. I have followed this SwiftlySalesforce link.

Here swiftly salesforce replaces your rootviewController with SFSafariViewController. Once login is done it will replace safari view controller with your initial rootviewController. I'm able to get all details of user from which I have logged in. Now on my initial view which is my rootview, I want to show chatter page which usually comes after successful login on webview. But I'm getting login page again on webview.

I think this is happening because the login seesion I'm getting from safari View controller is not getting to webview. Or is there any other issue?

If anyone have worked on such requirement, or anyone could help me, please post your answers here. Your help is appritiated.

Thank you,
Ankita

@NanostuffsTech
Copy link
Author

So basically I don't want to use any API rather I want to open URL to show content. Let me know if that's possible and how?

@mike4aday
Copy link
Owner

Hi @NanostuffsTech - not sure I understand what you're trying to do, but it sounds like you are building a web app, not a native iOS app. Is that correct? If so, then it would be better to build your app within Salesforce1. Can you share more details?

@mike4aday
Copy link
Owner

@NanostuffsTech maybe this will help: you can use the "front door" URL (in some cases) to pass a session ID to a web view: https://help.salesforce.com/articleView?id=000193348&language=en_US&type=1

@NanostuffsTech
Copy link
Author

Not really, it's native application only. What I'm trying to do is, login to Salesforce using Swiftly Salesforce and then show my own URL of chatter field which we can goto after logging in. But right now what is happening, it's allowing me to login through Safari but when I open my own web view in my controller, it shows me again login page when I try to open chatter field.

So what I want is my web view should use same session as of safari. So that other URL which I'm opening wont take me to login page but will directly open chatter field page. Let meknow if you need any more clarificaiton.

@mike4aday
Copy link
Owner

Hi @NanostuffsTech: I don't understand what you mean by "open a Chatter field" - but I believe I understand the larger question, i.e. how to pass a session ID to a web view that's loading a protected Salesforce URL. Is that correct? If so, then this might work:

  • Authenticate user via Swiftly Salesforce - once authenticated, you can access the current session ID at salesforce.authManager.authData?.accessToken

  • Redirect the user to your app (don't forget to register the redirect URL's scheme with iOS)

  • Use the session ID with the Salesforce 'front door' URL to load your web view -- note that the web view will have to follow redirects and store the session cookie provided by Salesforce

Does this help? Can you share the URL you're trying to load in the web view?

@NanostuffsTech
Copy link
Author

NanostuffsTech commented Jan 29, 2017 via email

@mike4aday
Copy link
Owner

@NanostuffsTech try using the access token as session ID with the 'front door' URL per my earlier post.

@TrupK
Copy link

TrupK commented Feb 3, 2017

Hello,
I have tried with 'front door' by using access token. But it's still not working for me. Any other solustion? Acutually whenever I'm trying to access TaskStore.shared.cache, I'm getting this nil. I'm not getting where and why this gets set to nil. Will this impact while calling url?

Thanks.

@mike4aday
Copy link
Owner

mike4aday commented Feb 7, 2017

Hi @TrupK - in what way is it not working?

Here's a related post: http://salesforce.stackexchange.com/questions/50368/how-to-integrate-salesforce-page-to-native-ios-app

And note also that your connected app has to allow web scope to enable web page access: https://help.salesforce.com/articleView?id=remoteaccess_oauth_scopes.htm&type=0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants