How to set FacebookUrlSchemeSuffix build hint in Codename One - ios

I have two free and paid apps which use same one Facebook app.
The free app has package: com.company.app
The paid app has package: com.company.app.free
The facebook app has id is 123456 and the iOS platform section in Facebook app:
"Bundle ID": com.company.app.free, com.company.app
"URL Scheme Suffix": free, paid
I can't logon the facebook in freeApp because the facebook always redirects to the paidApp.
After spend time, I found the Two iOS apps using the same Facebook app ID - is it possible? and https://developers.facebook.com/docs/ios/troubleshooting#sharedappid and try:
Add the ios.FacebookUrlSchemeSuffix="free" for freeApp and ios.FacebookUrlSchemeSuffix="paid" for paidApp but the problem is still same.
Then remove the ios.FacebookUrlSchemeSuffix build hint above, add the ios.plistInject=< key>FacebookUrlSchemeSuffix< /key>< string>free < /string> for freeApp and test it. The app is terminated immediately when start logon the facebook.
Then add the ios.urlScheme=fb123456 to the freeApp but the build is failed at server with error "...Info.plist': The data couldn’t be read because it isn’t in the correct format."
What are correct setting for ios.urlScheme and ios.plistInject build hints (include the FacebookUrlSchemeSuffix) in order for both freeApp and paidApp can work correctly in Codename One?

ios.urlScheme
Allows intercepting a URL call using the syntax
urlPrefix
From: https://www.codenameone.com/manual/advanced-topics.html
Notice that by default defining Facebook support includes the main URL scheme so the plistInject will conflict with that.

Related

Xcode 7 + canOpenURL, how to have Facebook and Twitter to open my own app links

Before Xcode 7, it was working fine. When I post link like "myapp://mylink?id=1" on Facebook and Twitter for social media sharing, the users can click on it and it will open my own iOS app if it is installed. I know xcode 7 put limit of 50 url schemes that any app can ask "canOpenUrl" before actually proceeding with "openUrl". Apparently Facebook and Twitter both still checking canOpenUrl before opening the link (they open in a UIWebView inside their apps), and since they can't add all the world's apps' custom url schemes into their app plist because of the 50 limit, my app now can't be opened from FB and Twitter with my custom url scheme. Log shows following on the console:
Twitter[827] <Warning>: -canOpenURL: failed for URL: "myapp://mylink?id=1" -
error: "This app is not allowed to query for scheme myapp"
Now the question is, is there any way I can have it working like before, where users can click on some link (myapp://mylink?id=1) on FB and Twitter, then that opens my own app through custom url scheme?
FYI, I actually post link like http://myweb.com/link?id=1 on those sites, and the link is processed on my webserver based on the HTTP header request to decide to redirect to actual web, or if iOS then redirect to myapp://mylink?id=1, and if Android then redirect to another url scheme for android app etc. I tested with just posting myapp://mylink?id=1 link directly on Facebook and Twitter, and it's still not working giving same error.
Add on:
The iOS9 new rules is that you need to add following, up to 50 of them, to your app plist so that your app can query the OS for canOpenURL, but it also renders unusable for big apps like FB & Twitter:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>myapp-custom-url-scheme</string>
</array>
To me from my reading around researching this issue, the solution is:
either Apple should change this restriction to more rate limit based, so that abusing apps (like Amazon something) wouldn't use it to scan for all known url schemes to build statistics of app installs,
or Facebook and Twitter etc big social media sites should stop checking canOpenURL, and just go ahead and openURL without verifying.
or even better, we should build some centralized database for custom URL scheme name spaces, and both iOS and the other apps should use it for this kind of general purposes.
OK, Facebook and Twitter recently released updates that have fixed this issue now.
Seems like they are not checking canOpenURL anymore, and letting any app's custom url scheme to open, unless they are doing some other ways to validate it.

Link to open up iOS app from facebook and twitter page and other ios app?

Hi I have a requirement in my app. From my ios Application(myapp),i share a link to facebook. Then I opened up my facebook account in browser or Facebook application and clicked the link, link should open in myapp if myapp is installed in the device otherwise link should open in browser. How can I achieve this ? Please suggest me step by step. Thanks in advance for your consideration and help.
I am not sure if this is possible. I have looked at various questions including
Is it possible to register a http+domain-based URL Scheme for iPhone apps, like YouTube and Maps?
as I am sure you might have already done but these questions target their own app, mainly web app, but you want that behavior to occur from an app that is not yours like twitter or facebook. But what you can do is show them two links on facebook/twitter, if they have installed press link 1 and if they want to install, press link 2 and you can pass parameters in link 1 as you might already know.
I will also keep checking answer of this question if some one comes and gives a better solution.
There is an option called custom URL scheme in iOS. It will help you to create a URL scheme which identifies your application. You can post link with this URL scheme and when you tap on this link on your iOS device it will open up your mobile app. Please see the link below to know how to setup this.
Custom URL Scheme in iOS
This is called 'deep URL linking'. Facebook have built a service called 'App Links', which seems pretty cool.
https://developers.facebook.com/docs/ios/app-links

redirect_uri_mismatch Unity Google API on iOS

I created an app in Unity with Google Play Leaderboard support. I could easily make it work on Android, then I moved to OSX to build it for iPhone too.
First I got a problem, that Apple won't accept any bundle identifier with the '_' character in it, but my Android app bundle identifier had 2 of them...
However I found out, that in the Google Developer Console I can link another app to my app (to use the same Leaderboard) for iOS too, so I was quite happy. Unfortunately this doesn't seem to work. I get the *redirect_uri_mismatch* error message every time I try to log in.
On Android I used the UnityGPGPlugin but as it didn't work for me on iOS, I tried the PlayGameServices too. In UnityGPGPlugin I could set only the Application ID, so I thought that's why it is not working. In the PlayGameServices plugin there are two fields, one for the Application ID and one for the Client ID that made it look like that's really what I need. Unfortunately the error is still present and I really don't know what I could do with it. Here is the well known message:
Error: redirect_uri_mismatch
Request Details
cookie_policy_enforce=false
scope=https://www.googleapis.com/auth/appstate
https://www.googleapis.com/auth/games
https://www.googleapis.com/auth/plus.login
https://www.googleapis.com/auth/plus.moments.write
https://www.googleapis.com/auth/plus.me
https://www.googleapis.com/auth/plus.profile.agerange.read
https://www.googleapis.com/auth/plus.profile.language.read
https://www.googleapis.com/auth/plus.circles.members.read
response_type=code
access_type=offline
redirect_uri= < my bundle identifier without '_' characters >:/oauth2callback
state=16885367
gpsdk=1.5.0
verifier=12647966
display=page
client_id=123456789123-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com
hl=en
The debug log contains only this:
2014-03-16 14:21:19.507 <my app>[1699:60b] GPGSAuthenticateWithCallback.
2014-03-16 14:21:19.509 <my app>[1699:60b] GPGSManager initializing and authenticating.
2014-03-16 14:21:19.512 <my app>[1699:60b] GPPSignIn initialized.
2014-03-16 14:21:19.514 <my app>[1699:60b] GPPSignIn attempting sign in now.
-> applicationWillResignActive()
-> applicationDidEnterBackground()
Does anyone know how could I solve this problem?
Thanks in advance!
Edit:
Maybe it wasn't obvious, but I have 2 bundle identifiers, both of them are linked to the same game service in Google Play Developer Console. The com.x.a_b_c belongs to the Android app, the com.x.abc belongs to the iOS app.
I was having redirect_uri_mismatch error while using UnityGPGPlugin. I was using "123456789123" as my Application ID instead of "123456789123-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".
However, I manage to get through the Google Sign In page after changing all my setup to "123456789123-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" as my Application ID. Including the GPGApplicationID in Info.plist.
Sad to say that I am having another problem now, but at least that's how I manage to get through that error. :)

"Login cancelled by player" callback in facebook api for Unity IOS (only if you have facebook app in device)

I am using unity facebook api 4.3.6 for ios. Its working perfectly fine if I don't have #facebookapp in my device. Once I download it and try login, it takes me to #facebookapp and redirect again to my game with callback
FB Login callback : {"is_logged_in":false, "user_id":"", "access_token":""}
Login cancelled by player
This happens only if I have facebook app downloaded! I think its some how cache issue but not sure exactly what is it. Any luck?
I believe this is not connected with Unity.
Here is few reasons I faced
You need to ask read and write permissions separately. Wait until you get read permissions than send request for write permission.
Make sure your app is allowed to login ( if you have FB app installed on your device )
Make sure you have your app bundle identifier added to developer.facebook.com
Here is what helped me fixed that problem with Unity Facebook-Android.
setting the sandbox mode ON:
Go to https://developers.facebook.com/apps
Select the respective app from the drop down.
Go to 'Status & Review' from the table in the left side of the page.
Do you want to make this app and all its live features available to the general public? - Select switch to set YES/NO value.
if the ON/OFF button is disable, please go back to Settings and enter a valid email address.
I understood why when the device is installed a facebook app, my app can't login facebook.
First : software OpenSSL create keyhass wrong. I have downloaded OpenSSL from here : http://code.google.com/p/openssl-for-windows/downloads/list , and it creates keyhash wrong.
I have used other OpenSSL sofware, you can download it here : https://www.dropbox.com/sh/t6tt44dc2nm6vza/6mp1W74GiZ , it is create keshash right.
Second: In class FacebookAndroidUtil.cs , line 62, you add System.Environment.GetEnvironmentVariable("HOMEDRIVE") before System.Environment.GetEnvironmentVariable("HOMEPATH"). Facebook SDK requires a file debug.keystore in : C:\Users\UserName.android\debug.keystore.
If the Unity Editor, Edit Setting Facebook has yet to create android debug hash key. Then use the Eclipse Software, create and run onr any project. Eclipse will generate a debug.keystore. If it is't create in folfer : C:\Users\UserName.android\debug.keystore , then find it, coppy and paste into C:\Users\UserName.android\debug.keystore
Third: publish your app in Facebook, so be sure it is:"This app is public and available to all users".

Facebook URL Schemes for both Free and Paid Apps

I have set up the URL scheme suffix on Facebook to have a "paid" and "free" version of my app. Now, I have submitted a paid and free version of my App on the App Store using 2 different bundle identifiers: com.mycompany.myapppaid and com.mycompany.myappfree. I have used the correct URL type for each app (fbMYFACEBOOKIDpaid, and fbMYFACEBOOKIDfree).
According to the Facebook app page, there is only a single spot for a single bundle identifier, how does Facebook differentiate between the two?
From a previous question I answered:
Mark your app as "Web".
Bundle ID is not necessary.
EDITED FOR NEW VERSION OF FACEBOOK IOS SDK:
- (id)initWithAppId:(NSString *)appId
urlSchemeSuffix:(NSString *)urlSchemeSuffix
andDelegate:(id<FBSessionDelegate>)delegate;
When you initialize the Facebook object, you need to initialize it with the appropriate "paid" or "free" suffix.
OLD ANSWER:
Call - (void)authorize:localAppId: accordingly
The key is to mark your App Type as "Web" instead of "Native/Desktop"
when you are filling out your app info on the Facebook create app
pages. When you are Native/Desktop app it requires the Bundle ID and
checks against that in the callback. If you are web app it ignores it.
You don't need to put anything in the web interface. When you want to
authorize facebook, call [_facebook authorize:_permissions
localAppId:#"free"]; or [_facebook authorize:_permissions
localAppId:#"paid"];

Resources