I'have used the following code to redirect the user to a facebook page.
NSURL *webURL = [NSURL URLWithString:#"https://m.facebook.com/icc"];
[[UIApplication sharedApplication] canOpenURL:webURL];
After updating to ios9, the above code is not working.
I have added following block in plist file. But not working.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb</string>
<string>fbauth2</string>
<string>fbshareextension</string>
<string>fb-messenger-api</string>
<string>twitter</string>
<string>whatsapp</string>
<string>wechat</string>
<string>line</string>
<string>instagram</string>
<string>kakaotalk</string>
<string>mqq</string>
<string>vk</string>
<string>mqq</string>
</array>
Is anything i missed here?
There are two URL related methods that are available. canOpenURL and openURL.
canOpenURL returns a yes or no answer after checking if there is any apps installed on the device that know how to handle a given URL.
openURL is used to actually launch the URL, which will typically leave the app and open the URL in another app.
And in your case i have tried the same code its working fine for me i means in case of canOpenURL its returning YES and when i call openURL its opening the safari and yes its same what you did.
For all developers having the same issue, the solution is to add a whitelist of all URL schemes your App may need to call into the Info.plist. The key to add is LSApplicationQueriesSchemes and its value is an array with all the URL schemes.
Related
I am working with twitter SDK to integrate with in ios app.When i follow all the step and create the customer key and put it in my app.When I run the app it show
"[TwitterKit] did encounter error with message
"Error obtaining user auth token.": Error Domain=TWTRLogInErrorDomain
Code=-1 "Callback URL not approved for this client application.
Approved callback URLs can be adjusted in your application
settings" UserInfo={NSLocalizedDescription=Callback URL
not approved for this client application. Approved callback URLs can
be adjusted in your application settings"
How to resolve this?
I had the same problem and the TwitterKit documentation is not accurate or Twitter has changed their policies. In any case, on the Twitter Apps site, the callback URL has to be set very specifically. The callback URL should be in the format:
twitterkit-{consumer/api key}://
For example:
twitterkit-128238aKjqlp123AKdasdf://
Also, this needs to be registered in your Info.plist exactly the same:
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>twitterkit-128238aKjqlp123AKdasdf</string>
</array>
</dict>
More documentation is listed here: https://developer.twitter.com/en/docs/basics/callback_url.html
I just added on callback url field twitterkit-<api/consumer Key>://.
If you have an apiKey like abc you should add twitterkit-abc://. This work for iOS, for Android just add twittersdk://.
To Fix this issue do as below:
[Mandatory]
Add CallbackURL into the dashboard as below format:
For iOS:
twitterkit-CONSUMERKEY://
For Android:
twittersdk://
Help Link:
https://twittercommunity.com/t/ios-twitter-login-error-code-415/107775
[ Note: Please replace your consumer key in place of words "CONSUMERKEY" in above format]
My solution: I hope it's useful.
Go to https://apps.twitter.com
Then in the "Settings" tab of your app.
Fill the "Callback URLs" form.
According to this documentation i guess you just have to enter a valid URL :
https://github.com/twitter/twitter-kit-ios/wiki/Installation
NOTE: Although the callback URL will not be requested by Twitter Kit in your app, it must be set to a valid URL for the app to work with the SDK.
Hey everyone here is a simple fix that worked for me.
Go to: https://apps.twitter.com
Go into the settings tab.
Under Terms of Service URL uncheck the box that says:
"Unable Callback Locking"
Now test your app.
Finally I found the solution for my case. Hope it'll help someone else
Put this in URL Callback field.
twittersdk://
Refer: https://github.com/twitter/twitter-kit-android/issues/135
I'm having problems opening the app store (to suggest an app update).
This is what i'm doing:
NSURL *url = [NSURL URLWithString:#"macappstore://itunes.apple.com/app/id[my_id]?mt=12"];
if ([[UIApplication sharedApplication] canOpenURL:url]){
[[UIApplication sharedApplication] openURL:url];
}
canOpenURL is returning false, also i tried without the conditional but it doesn't work.
In addition i tried to use NSWorkspace instead the openURL method in UIApplication but i'm having compilation errors, surely this are dependencies issues but i couldn't find Cocoa.framework and neither AppKit.framework to add one of them to the binaryLibraries of my project.
For iOS, you should be using the prefix itms-apps:// instead of macappstore://. This will link you directly to the App Store app, instead of through a Safari redirect (as http:// or https:// will do).
Lots more on this topic covered here:
How to link to apps on the app store
I have setup a view in my appcelerator titanium app to be nearly identical to the one in the kitchen sink demo for facebook login. I want to use single sign on for IOS:
//LoginView Component Constructor
function LoginView() {
//create object instance, a parasitic subclass of Observable
var self = Ti.UI.createView();
// APP ID BELOW IS CHANGED FOR DEMO PURPOSES
Titanium.Facebook.appid = "111111111111111";
Titanium.Facebook.permissions = ['email', 'publish_actions'];
// ENABLE SINGLE SIGN ON
Titanium.Facebook.forceDialogAuth = false;
self.add(Titanium.Facebook.createLoginButton({
style:Ti.Facebook.BUTTON_STYLE_WIDE,
bottom:30
}));
return self;
}
module.exports = LoginView;
When clicking the login button, it successfully opens the facebook login dialog in safari and I login. Then when it tries to take me back to the app, I get the error:
Cannot Open the Page Safari cannot open the page because the address
is invalid
Very similar code works correctly in the kitchen sink app, and also disabling single sign on makes logging in through facebook work correctly in my app.
All I have for the settings in the facebook app is:
Facebook Login - Enabled
Am I missing anything from the settings?
Figured it out:
In my facebook app settings (on developers.facebook.com), I set the bundle Id to the same id as my app in Appcelerator.
Based on the q & a:
Copied Info.plist from build/iphone/ into the root of the application.
Added the xml element fb111111111111111 below under app to Info.plist:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.mycompany.app</string>
<key>CFBundleURLSchemes</key>
<array>
<string>app</string>
<string>fb111111111111111</string>
</array>
</dict>
</array>
Where 111111111111111 is changed to the id of the app
I want to open iphone apps like Contacts and Calendar from within my phonegap app, I don't mind that doing so will put my app in the background. I can open the browser and using window.open but how do I open other apps?
eg window.open("contacts://", '_blank'); doesn't work
The only way that one app, PhoneGap-based or otherwise, can cause another app to launch is to open an URL that uses the target app's custom URL scheme. So, if the Contacts app supports some custom scheme, you're in luck. If not, you're out of luck.
You are going to need to write a custom phonegap plugin so that you can access custom methods you write in objective C.
The official phonegap documentation is here.
I'll briefly explain how you will do this.
In your javascript you will call this code :
PhoneGap.exec("OpenMailAppPlugin.openMailApp",parameter1);
In objective C you will create a new file OpenMailAppPlugin class. Read the link above for exact instuctions, but the important method will be soemthing like this.
-(void) openMailApp:(NSMutableArray*)paramArray withDict:(NSMutableDictionary*)options {
NSString *parameter1 = [paramArray objectAtIndex:0]; //recieves information from javascript function
NSURL* mailURL = [NSURL URLWithString: #"mailto:%#?cc=bar#example.com&subject=Greetings%20from%Cupertino!&body=Wish%20you%20were%20here!",paramter1];
[[UIApplication sharedApplication] openURL: mailURL];
}
additionally, you may be interested in sending information back to your phonegap application. You can do this by injecting a javascript call that sends parameters. In your objective C function you would do something like this.
NSString * jsCallBack = [NSString stringWithFormat:#"myJavascriptFunction('%#');",parameter];
[self.webView stringByEvaluatingJavaScriptFromString:jsCallBack];
As previously answered, using a URL scheme can work. If you have several apps and you want to be able to open one from the other, then it's really simple when using PhoneGap build: you just need to add the URL scheme to your config.xml file, eg:
// In config.xml
<gap:url-scheme>
<scheme>app1scheme</scheme>
</gap:url-scheme>
Then from your other app you'll just have a link to app1scheme://, eg simply
Start App1
Here is the list of all the iOS/iPhone app url
Video - video:
Music - music:
Youtube - youtube.com
iTunes store - itms:
iBooks - itms-books:
App Store - itms-apps:
Mail sending - mailto:
Telephone - tel:
More can be found at this outdated link
http://www.wiki.akosma.com/IPhone_URL_Schemes
Look at this on how you can implement your's url
https://appurl.org/docs-handling-android
Need to use a plugin, unfortunately you need native ios code:
This one works:
https://github.com/phonegap/phonegap-plugins/tree/master/iOS/ExternalFileUtil
I am going to develop a iPhone application.
In that i need to run another iPhone app when the user clicks on the button.
Is it possible to run a iPhone app from another iPhone app?
If possible, Please let me know your inputs on this.
Thanks for any help.
[copy and paste of a previous answer I gave here for the click-averse]
You can use the url scheme built into iOS. For example, you could call Safari with a url because it is registered as the application which handles the http URL scheme
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.google.com/"]]
The openURL: method is an instance method of the singleton UIApplication instance, on which you can call any application installed which registers in its plist an ability to handle some sort of input data.
Here's a list of common url schemes in iOS.
A little known way to detect the existence of another application on a device is to use canOpenURL: on the same singleton instance:
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"cydia://"]])
{
NSLog(#"cydia installed");
}
else
{
NSLog(#"cydia not installed");
}
Only if that other app is already installed and run and has been designed to register a custom URL handler to itself with the OS.
The your app can run it by using that custom URL scheme.
If the app has a custom URL Schema and you know what it is, then it is possible to launch another app form yours.
When user pressed the button, your current app will close and run the new app..
Yea.. Its possible.. BUT you must know the "short link" of the other app.. I tried it before and even successfully transferred data from the lite version to the full version..
Its called url scheme..
Here's a link:
http://www.idev101.com/code/Objective-C/custom_url_schemes.html
Hope it can achieve what you want..