WKWebView in Blackberry Dynamics iOS app cannot save cookies - xamarin

We have a Xamarin.iOS app which uses the Blackberry Dynamics SDK. (v11.0.1.11)
In this app we show a WKWebView, which loads a page that uses cookie based authentication. The problem is, that cookies seem not to be correctly saved. During loading of the WKWebView I see entries like this in the console output:
2023-01-17 13:16:34.765 MyApp[1110:277171] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///private/var/mobile/Containers/Data/Application/7FB9EDEF-FB4A-4E7B-A8B0-E02C209D1F20/Library/Cookies/Cookies.binarycookies
2023-01-17 13:16:34.779 MyApp[1110:277171] could not create directory "/private/var/mobile/Containers/Data/Application/7FB9EDEF-FB4A-4E7B-A8B0-E02C209D1F20/Library/Cookies" for future sandbox extension, error Error Domain=NSCocoaErrorDomain Code=516 "The file “Cookies” couldn’t be saved in the folder “Library” because a file with the same name already exists." UserInfo={NSFilePath=/private/var/mobile/Containers/Data/Application/7FB9EDEF-FB4A-4E7B-A8B0-E02C209D1F20/Library/Cookies, NSUnderlyingError=0x28237d8f0 {Error Domain=NSPOSIXErrorDomain Code=17 "File exists"}}
Then when the WebView loads it gets a "401 - Unauthorized" from the server because (I assume) the cookie is missing. Doing the same in our version of the app not using the Blackberry SDK we do not get this log entry and the page loads without problems. Any idea why cookies cannot be saved in the Blackberry version?

Related

ASWebAuthenticationSession in MacOS 10.15 (Catalina)

I am trying to implement the new ASWebAuthenticationSession in MacOS 10.15 and I'm getting a bit confused about the callbackURLScheme.
The header file for ASWebAuthenticationSession says:
The callback URL usually has a custom URL scheme. For the app to
receive the callback URL, it needs to either register the custom URL
scheme in its Info.plist, or set the scheme to callbackURLScheme
argument in the initializer.
So I initialize like this:
self.webAuthSession = [[ASWebAuthenticationSession alloc] initWithURL:self.authURL
callbackURLScheme:#"myurlscheme://"
completionHandler:^(NSURL * _Nullable callbackURL, NSError * _Nullable error) {
}];
The oauth provider I am trying to access, does not support custom URL schemes, so I have it set to redirect to a web address which in turn redirects to my URL Scheme.
So, after clicking Login in my MacOS app, Safari presents a window that allows me to login to the service. After successfully logging in the redirect happens but the web page just goes to a screen saying
Safari can't open the specified address.
I can see that the address is myurlscheme://?code=1234567890abcdefgetc... which is correct but it's obviously not calling the ASWebAuthenticationSession callback.
If I add the URL Scheme to the plist, then the safari window shows a prompt asking if you want to open it in the my app.
I know I can then fetch the code from the App Delegate's application:openURLs: method, but this is fiddly, has an unnecessary prompt for the user to click, and also leaves the ASWebAuth... safari window open. This should all be automatic through the callback.
The only way I get the callback to fire, is by closing the safari window in which case it calls back with error.
I have just returned to this to try again and it seems to be working fine on MacOS 10.15.1 and 10.15.2 beta.
I have noticed that the callbackURLScheme parameter must not include ://
I'm not able to go back and test it again on 10.15 but i'm happy to use this now assuming everyone on 10.15 would have updated to 10.15.1
Darren is right in MacOS you must remove the :// from the callbackURLScheme. iOS works fine no matter if you :// or not. However, in MacOS Catalyst there seems to be a bug. My app is getting focused once I login, but isn't getting the callback. Haven't found a way to fix it yet.

react-native VS android emulator chrome debugger error "Cannot set property 'volume' of null"

I am trying to debug react-native app running on VS emulator in chrome. The error I am getting at the moment is "Cannot set property 'volume' of null". It is like 4th or 5th cryptic error I am getting since starting, but the first one when I hit the wall. I will outline all configuration steps in case I botched something earlier:
Initialized project with react-native init myapp
Started the bundle server with react-native start --host 192.168.100.4 (the reason for host parameter is CORS error)
Started the app with "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && react-native run-android" (the reason for react-native bundle command is assets error)
On emulator went to shake -> Dev Settings -> Debug server host & port for device, set it to 192.168.100.4:8081 (the reason for that is "cannot connect to bundle server on localhost)
shake -> Debug JS Remotely
Chrome window opens, I hit F12. Now it still displays CORS error for a while, but after some page refreshes it displays "Cannot set property 'volume' of null" and sticks to it:
(index):94 Uncaught TypeError: Cannot set property 'volume' of null
at Object.render ((index):94)
at Object.setState ((index):48)
at WebSocket.ws.onopen ((index):152)
Just in case, here is CORS error that I get initially:
Failed to load
http://localhost:8081/index.delta?platform=android&dev=true&minify=false:
No 'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'http://192.168.100.4:8081' is therefore not allowed
access. If an opaque response serves your needs, set the request's
mode to 'no-cors' to fetch the resource with CORS disabled.
(index):188 Uncaught (in promise) TypeError: Failed to fetch
It goes away after page refresh, but I wonder why it still happening.
Did anyone manage to setup Chrome Debugging with VS emulator and react-native? If so, please share your experience, all tutorials I found just happily advice to run react-native start and react-native run-android and everything should be smooth ride after that )
I had a similar issue with the debugger mode and was getting an error.
I am not sure of the WHY? to that answer but the extensions in the chrome might be the problems. I disabled the extensions and I didn't get any of the errors post that.
Open the application
Select DevSettings
Choose Debug server host & port for device.
Type your system ip address along with the port number of the metro
builder.
For getting system ip address.
Open command prompt
Type ipconfig
Select ipv4 address

Parse related remote calls failing in app

I have developed an Ionic Framework App using Parse which works great on my desktop browsers. No errors or warnings in the browser console.
But when I package the app and test in on my actual Android 4.4.4 device, the Parse related functionalities does not work. When I tried to debug the App by installing the .apk using GapDebug tool, I see the below in the console.
POST https://api.parse.com/1/login net::ERR_CACHE_MISS
POST https://api.parse.com/1/requestPasswordReset net::ERR_CACHE_MISS
Below is the complete console log details for the Parse Login activity.
POST https://api.parse.com/1/login net::ERR_CACHE_MISS parse-1.3.3.min.js:1
b._ajax parse-1.3.3.min.js:1
b._request parse-1.3.3.min.js:1
b.User.b.Object.extend.logIn parse-1.3.3.min.js:3
b.User.b.Object.extend.logIn parse-1.3.3.min.js:3
$scope.validateUser login.controller.js:22
$parseFunctionCall ionic.bundle.js:20124
(anonymous function) ionic.bundle.js:50863
Scope.$eval ionic.bundle.js:22178
Scope.$apply ionic.bundle.js:22276
(anonymous function) ionic.bundle.js:50862
jQuery.event.dispatch jquery.js:4409
elemData.handle jquery.js:4095
triggerMouseEvent ionic.bundle.js:2811
tapClick ionic.bundle.js:2800
tapTouchEnd ionic.bundle.js:2918
POST https://api.parse.com/1/requestPasswordReset net::ERR_CACHE_MISS
For getting all the data for a particular class, I get the below failure object.
Failed to load resource: net::ERR_CACHE_MISS https://api.parse.com/1/Items
XMLHttpRequest failed: {"statusText":"","status":0,"response":"","responseType":"","responseXML":null,"responseText":"","upload":{"ontimeout":null,"onprogress":null,"onloadstart":null,"onloadend":null,"onload":null,"onerror":null,"onabort":null},"withCredentials":false,"readyState":4,"timeout":0,"ontimeout":null,"onprogress":null,"onloadstart":null,"onloadend":null,"onload":null,"onerror":null,"onabort":null}
The issue was with permission. It was failing because the app was not able to connect to internet.
Somehow the Network Access permission entry got deleted in the manifest file. After adding it to manifest, it worked.

xcode project always gets facebook login fail status

I encountered a facebook login problem. I installed FB SDK 3.0 and sample projects seemly run well --- not quite sure though. When I create a button in my own project and try to log in to Facebook, I always get FBSessionStateClosedLoginFailed from sessionStateChanged method, although I apparently get the page "You have already authorized this app. Press Okay to continue". I also tried log out through Simulator Safari facebook page, and re-launched my project and I got new username/password page and I then logged in, but I still get FBSessionStateClosedLoginFailed!
A few more observations.
1, I got FBSessionStateClosedLoginFailed thru NSLog, the log comes up right after I clicked Okay button on the Facebook page "You have already authorized this app.
2, I tried clean xcode project cache, but no help.
Kind of frustrated. I wonder if any of you can help on this problem. Appreciated!
-Tony
Addition:
I did a bit more research, and I found what I have is probably a typical problem, as Facebook highlight here ("Pro-tip 3: Complete all iOS App Settings" section in page http://developers.facebook.com/docs/howtos/login-with-facebook-using-ios-sdk/). The image with a big red cross over iPhone is exactly what I have. From xcode project, I click my login button, and I'm directed to this page, and every time I have to click "Okay" on this page (let me call it Okay_page) to go back to my app in Simulator, however with login status as FBSessionStateClosedLoginFailed. I checked bundle ID, I have it correct. I don't have a 'YOUR_IPHONE_APP_STORE_ID' yet, which I believe I need pay Apple to get and I will do it later but not while I'm still working on it.
Now get a couple of questions:
1, Do I have to have YOUR_IPHONE_APP_STORE_ID to skip this Okay_page?
2, Does this (not automatically re-directed back to my app from this Okay_page) have anything to do with that I always get a login status of FBSessionStateClosedLoginFailed when I manually click Okay in this Okay_page and return to my app in Simulator? In another word, is (that I have to manually click Okay to get back to my app in Simulator) (the reason I got a status of FBSessionStateClosedLoginFailed)?
Did you have set this function in AppDelegate?
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [FBSession.activeSession handleOpenURL:url];
}
I had the same issue:
We created the facebook app (developer.facebook.com) setting our
bundle id (ex. com.MyCompany.MyApp)
Off course, created our iOS app with the same bundle id
After delivered our app to the client, he changed the bundle id
without notify us.
Obviously he started to get FBSessionStateClosedLoginFailed errors!
So, you probably have different bundle id's between your iOS project and your Facebook App.
I had this error and couldn't resolve it for quite some time. It turns out that if you are using the native iOS Facebook account in settings and choose "no" for allow Facebook for this app, the app is blocked by the OS. You will always get the FBSessionStateClosedLoginFailed error and there is nothing you can do inside the code to fix this (99% sure). The best you can do is alert the user to check out the settings.
i am typing wrong line in given below method. self.session was nil
return [self.session handleOpenURL:url];
it should be
return [[FBSession activeSession] handleOpenURL:url];
Use Following Method.
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
// attempt to extract a token from the url
return [[FBSession activeSession] handleOpenURL:url];
// return [self.session handleOpenURL:url];
}
I fixed this problem after I reset the simulator. iOS Simulator - Reset Content and Settings..., hope to help.
I had this issue because I was calling [FBSession.activeSession close] in my applicationDidEnterBackground: app delegate callback. This closed the session so that when the redirect brought the app back up to open the session, it failed because it had been put into the closed state.
Make sure that you're not closing the session anywhere before you get to the Okay page.
go to Facebook.com. Open your application on the left panel -> Status & Review -> there is a toggle with text "Do you want to make this app and all its live features available to the general public?". Turn it on
well. I followed FBLoginCustomUISample somewhere on github.com and it was a working example of facebook login implementation from facebook itself. You can also read my workaround while creating facebook login feature in a iOS app. Here is a link form me:
Native iOS Facebook SSO won't return to app

Blank login page on CSWinPhone7SimpleApp

I'm trying to use the Facebook C# SDK from Codeplex on my WP7 app. I managed to build & run the application by manually adding Facebook.dll and Microsoft.Contracts.dll. But I only see a blank login(?) page :
The code enters FacebookLoginBrowser_Navigated, after loading this url :
http://www.facebook.com/dialog/oauth/?response_type=token&display=touch&scope=user_about_me,read_notifications&client_id=119779898114420&redirect_uri=http://www.facebook.com/connect/login_success.html
but the URL seems to have been redirected to this one :
http://m.facebook.com/login.php?app_id=119779898114420&cancel=http://www.facebook.com/connect/login_success.html?error_reason=user_denied&error=access_denied&error_description=The+user+denied+your+request.&fbconnect=1&next=http://www.facebook.com/connect/uiserver.php?method=permissions.request&app_id=119779898114420&display=touch&redirect_uri=http%253A%252F%252Fwww.facebook.com%252Fconnect%252Flogin_success.html&response_type=token&fbconnect=1&perms=user_about_me%252Cread_notifications&from_login=1&rcount=1
The important part is "User denied access", which I didn't, since I don't see anything except a blank page.
Thanks in advance !
edit: pasting the first url into an iPhone simulator Safari.app, I see the Facebook login screen, then after login, I see the grant permission screen...
your browser is not script enabled, try to set the flag at true :

Resources