facebook ios sso getting "safari cannot open page" error - ios

I've been developing an app for android and iphone, and been able to implement sso on android but when I try to implement it on iOS I get the above mentioned error :
"Safari cannot open the page because the address is invalid"
The error is shown after I click "okay" to give the permissions to my personal information on facebook to the app
the link in question is : m.facebook.com/dialog/oauth?refid=0
here is my info.plist file
<plist version="1.0">
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>icon.png</string>
<string>icon#2x.png</string>
<string>icon-72.png</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>icon.png</string>
<key>CFBundleIdentifier</key>
<string>com.snizilica.app</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSMainNibFile</key>
<string></string>
<key>NSMainNibFile~ipad</key>
<string></string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>[com.facebook.test]</string>
<key>CFBundleURLSchemes</key>
<array>
<string>fb[xxxxxxxxxxxxxxx]</string>
</array>
</dict>
</array>
where xxxxxxxxxxx is my app_id

Had the same problem. Solved it having removed the square brackets in the app id
...rfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb123456789012345</string>
</array>
</dict>
</array>
</dict>
</plist>
dont use any square bracets around the app id

Related

Snapchat Login Kit is unable to redirect to my app

I try to use Snapchat's Login Kit. But it doesn't redirect to my app after authentication.
I used this Login Kit before which is still working now. So I also compared both info.plist which are identical except for "SCSDKClientId", "SCSDKRedirectUrl" and "CFBundleURLSchemes"
Here's my info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>MY_APP_NAME</string>
</array>
</dict>
</array>
<key>SCSDKClientId</key>
<string>MY_SCSDK_CLIENT_ID</string>
<key>SCSDKRedirectUrl</key>
<string>MY_APP_NAME://snap-kit/oauth2</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>itms-apps</string>
<string>snapchat</string>
<string>bitmoji-sdk</string>
</array>
<key>SCSDKScopes</key>
<array>
<string>https://auth.snapchat.com/oauth2/api/user.bitmoji.avatar</string>
</array>
</dict>
</plist>
I make sure that the SCSDKRedirectUrl is the same as the developer portal one
The following function gets called.
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if SCSDKLoginClient.application(app, open: url, options: options) {return true}
return false
}
But SCSDKLoginClient.application(app, open: url, options: options) returns false all the time.
I'm out of ideas why this happens now. Any thoughts will be appreciated.
Update: I missed the SceneDelegate part for ios13. The solution can be find here: SnapKit fails return to app after logging into Snapchat
I have been struggling with this problem for some time now and I wish that the Snap Kit Documentation would provide more insight on this. Essentially, you may have not set up your URL Schemes. This actually isn't a Snap Chat problem but a p.list problem. You can check if your app allows redirects using safari. Here is the article I read, good luck!
https://kitefaster.com/2016/07/13/how-to-open-ios-app-with-custom-url/

Open an emailed text file with my swift2 iOS app

I have read this: open text files with my ios app and it's great in the fact that it allows me to see my app as one of the options to open it with and when selecting my app it opens my app but that's it. There are two problems:
First of all, while "opening with" for example Google drive says "Copy to Drive", while mine says "Copy to (null)" when I want it to say "Copy to HotSpotRIS". How can I do this? At least the app icon shows up. If it helps, my overall bundle identifier for my entire project is www.epicode.com.HotSpotRIS. Here are three pictures showing you what I am specifically talking about where the first picture is showing you the emailed txt, second is the user holding down on the txt file, and the third is the "open with" menu that pops up from this with my app reading "Copy to (null)":
Second of all, I know how to read and write text files and how to navigate the iOS file system but how do I connect my code to the .plist file in order to read the emailed txt file? I am guessing there needs to be some identifier that I can then use to call to obtain the txt data. Here is my info.plist file so far with the last bit of the file being the code I got from open text files with my ios app:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleGetInfoString</key>
<string></string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>NSLocationWhenInUseUsage</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>CFBundleDisplayName</key>
<string></string>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>Text File</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleTypeExtensions</key>
<array>
<string>txt</string>
<string>TXT</string>
</array>
<key>LSHandlerRank</key>
<string>Alternate</string>
<key>LSItemContentTypes</key>
<array>
<string>www.epicode.com.HotSpotRIS.txt</string>
</array>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.text</string>
</array>
<key>UTTypeDescription</key>
<string>Plain Text Document</string>
<key>UTTypeIdentifier</key>
<string>www.epicode.com.HotSpotRIS.txt</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>txt</string>
<key>public.mime-type</key>
<string>text/plain</string>
</dict>
</dict>
</array>
</dict>
</plist>
Thank you in advance!

Facebook Share iOS Swift

I'm trying to use Facebook sharing SDK in my iOS app.
I followed the steps in the Facebook Developer Website. But I have an issue, the problem is that Facebook is not showing the app name on posts published by my app as you can see in the screenshot below.
and I have some errors in the logs :
-canOpenURL: failed for URL: "fbapi20150629:/" - error: "This app is not allowed to query for scheme fbapi20150629"
plugin com.apple.share.Facebook.post invalidated
but the photo is shared without any issue, the only problem is that there is not the app name on the post shared.
But when sharing a ContentLink I see the app name on the post, it doesn't work on photos !!
here is my code to share in iOS :
let image = UIImage(data:imageData!)
let content: FBSDKSharePhotoContent = FBSDKSharePhotoContent()
let photo: FBSDKSharePhoto = FBSDKSharePhoto()
photo.image = image
photo.userGenerated = true
content.photos = [photo]
FBSDKShareDialog.showFromViewController(self, withContent: content, delegate: nil)
info.plist :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>fr_FR</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.3.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UIAppFonts</key>
<array>
<string>master_of_break.otf</string>
</array>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb100967589******</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>100967589******</string>
<key>FacebookDisplayName</key>
<string>Athéna</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
</dict>
</plist>
Post shared with app name (it works on Android )
Why don't you use Social Framework to implement this ? Its very easy to implement and displays text, url , photo .
You just have to follow the below steps :-
1) Goto your app -> Build phases
2) Click on Link Binary with Libraries and add Social framework
3) In your View Controller import <Social/Social.h>
4) In your sharing action write the below code :-
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook)
{
let fbShare = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
fbShare.setInitialText("Swift programming")
fbShare.addURL(NSURL(string: filePath))
fbShare.addImage(UIImage(named:"ImageName"))
self.presentViewController(fbShare, animated: true, completion: nil)
}
Else you can follow the below link for integration :-
http://www.theappguruz.com/blog/facebook-integration-using-swift
To show your app link refer this :-
https://developers.facebook.com/docs/applinks/ios
Add the following items to your info.plist

iOS) Where should I copy & paste facebook XML snippet?

I'm making Facebook Login, I followed all the steps very well but Configuring my info.plist. My xml code is below:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb12345678</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>12345678</string>
<key>FacebookDisplayName</key>
<string>AppName</string>
I add this xml to the section of 'dict' at info.plist in my project not my projectTest.
So finally, I finished my .plist xml file
But I got an error
error: couldn't parse contents of '/Users/~/Desktop/app/app/myproject/Info.plist': The data couldn’t be read because it isn’t in the correct format.
How can I solve this?
UPDATE
Entire .plist is below :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.myproject.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
/*FACEBOOK XML IS JUST BELOW*/
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb12345678</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>12345678</string>
<key>FacebookDisplayName</key>
<string>AppName</string>
/**/
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
You are adding the snippet in wrong position:
<key>UIRequiredDeviceCapabilities</key> <<----- this one should go with
/*FACEBOOK XML IS JUST BELOW*/
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb12345678</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>12345678</string>
<key>FacebookDisplayName</key>
<string>AppName</string>
/**/
<array> << ------------- this one
<string>armv7</string>
</array>
Add fb snippet before
<key>UIRequiredDeviceCapabilities</key>
or after
<array> << ------------- this one
<string>armv7</string>
</array>

Newsstand Icon doesn't show in Xcode 5 iOS 6.1 SDK

Since upgrading Xcode to v5 and converting launch and app icon images to image asset catalogs, I've been unable to see the Newsstand icon of my app in the Newsstand on iOS 6.1 and iOS 7. Instead I see the regular app icon in its place. I'm still compiling against iOS SDK 6.1 because of obvious style changes in iOS 7 that I haven't been able to test in depth, yet.
That said, here is what I've tried on my Newsstand icon, icon-newsstand.png:
Converting the icon-newsstand.png into an asset catalog located in ./Images.xcassets/icon-newsstand.imageset/icon-newsstand.png.
Keeping icon-newsstand.png in my Resources folder as a part of the project.
Neither of these solutions work. Here is my info.plist for reference also. I've redacted the app names, just FYI.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>---- ----</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIcons</key>
<dict>
<key>UINewsstandIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>icon-newsstand.png</string>
</array>
<key>UINewsstandBindingEdge</key>
<string>UINewsstandBindingEdgeLeft</string>
<key>UINewsstandBindingType</key>
<string>UINewsstandBindingTypeMagazine</string>
</dict>
</dict>
<key>UIBackgroundModes</key>
<array>
<string>newsstand-content</string>
</array>
<key>UINewsstandApp</key>
<true/>
<key>CFBundleIdentifier</key>
<string>com.----.----</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.1</string>
<key>CFBundleName</key>
<string>---- ----</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2.0.1.13830</string> <!-- The Version of the app. -->
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIPrerenderedIcon</key>
<true/>
<key>UIStatusBarHidden</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>FB Connect</string>
<key>CFBundleURLSchemes</key>
<array>
<string>fb150871295037449------</string><!-- The app id must be appended to the end of this string. Example: <string>fb150871295037449connections</string> -->
</array>
</dict>
</array>
</dict>
</plist>
Has anyone run into this yet after upgrading Xcode and converting to image asset catalogs? And does anyone have any ideas where to start with changes to my project? So far from my searches, details online and on StackOverflow have been sparse in terms of Newsstand and Xcode 5 issues.
I'd greatly appreciate any help. Thank you!
I found out that the issue was only happening with iPads. Since that discovery, I realized that there was a section missing from my info.plist that looks like this:
<key>CFBundleIcons~ipad</key>
<dict>
<key>UINewsstandIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>icon-newsstand.png</string>
</array>
<key>UINewsstandBindingEdge</key>
<string>UINewsstandBindingEdgeLeft</string>
<key>UINewsstandBindingType</key>
<string>UINewsstandBindingTypeMagazine</string>
</dict>
</dict>
Mystery solved!

Resources