There are apps in the iOS app store that let you send encrypted messages via sms and it seems like they are using NSURL to create a clickable link that opens their app automatically (from the iMessage app) with the "hidden message" already showing in the app.
My question is, how does one store information within an NSURL? I figured out who to launch my app from another app using NSURL but how can you store extra information for the launched app to use such as text, an image, or a link to an online video?
I apologize if this is a basic question, I haven't had to work with URLs much. Many thanks.
We can achieve communication between apps through the URL Schemes concept.
if you can go through this link below, you will get some idea on how to share data between the applications
http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-working-with-url-schemes/
When you register an URL scheme in your application's info.plist like myapp you can use the following url's to invoke your application.
myapp://
myapp://some/path/here
myapp://?foo=1&bar=2
myapp://some/path/here?foo=1&bar=2
And you can check the received url's in the
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
method of app delegate and do the action according to each url.
Reference : Launching application via custom url scheme
The data is not stored in NSURL. However, you can pass parameters along with the URL and accordingly retrieve them in the new opened app.
Now you can use these params in the way you want.
Related
Obviously I must be missing something.
When I press my Google + button, it opens up safari and prompts for the login. Everything is fine until I complete the login procress. Safari tells me "Cannot open the Page -- Safari cannot open the page because the address is invalid". It never takes me back to my app, but keeps Safari open and goes to google.com.
I was thinking this would take care of that, but break points aren't ever going off in this method. Maybe I'm misunderstanding how it works.
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation];
}
Thanks for any help you can provide
Take look to the Bundle Identifier that is in your project and that you have registered with https://code.google.com/apis/console . Both of them should be same. After that make sure also you have set that same URL Schemes in URL Types in your application plist file.
I had this same problem today. I finally compared the sample app (included w/ SDK) line by line before I figured my problem out.
I didn't realize the ClientID found in the Developers Console was in standard domain name order while the URL Scheme for 1 of the 2 URL Types in the project settings (Info.plist) needs to be in reverse domain name notation
ClientID in Developers Console is [guid].apps.googleusercontent.com
URL Scheme in Info.plist is com.googleusercontent.apps.[guid]
I have set up a custom deep-linking iOS URL scheme for my app, and I listen for it in
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
I parse the URL and send a notification using NSNotificationCenter, with the URL as the object, to the appropriate class to handle the URL.
This all works great when the app is "backgrounded" but when the app is fully closed out of multitasking, it seems like the notification never gets sent (or received). Am I missing something about the process of notifications when the app isn't in backgrounding? Is there another way to pass along the information from the URL? Or is there at least a way to tell if the app is coming out of backgrounding or if it is a fresh launch?
Thanks!
You should check the launchOptions dictionary that is passed into applicationDidFinishLuanching:withOptions:.
For full details on what is included in the options dictionary: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html
I have an issue while integrating flickr in iOS app.
When I click on authorize button then it shows alert message as safari cannot open webpage because the address is invalid.
If anyone knows then please help me.
Thanks in advance.
My best guess is you are missing URL SCHEME in your project plist. Below is the screenshot showing current sample from flickr sdk which I downloaded from github and there is a setup done for URL Scheme handling.
Its called oAuth handling when SAFARI is finished verifying the credentials and want to return to the application it returns URL which can be handled by the application mentioned in plist and which we will handle from application delegate using following function
So you need to provide your URL identifier and URL Scheme for your project which you can get if you register in flickr api.
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
}
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 new to iphone application development.
I have a sample application that needs to be launched from a SMS message. I have no idea on how to do this. Please help me.
Note that if SMS operates in the same manner as Mail on the iPhone, you'll need to enclose your custom URL in brackets to make it launch the application responding to that scheme. For example,
<yourapp://yoururl>
will work, but
yourapp://yoururl
will not.
Allow your application to respond to some url (eg: myapp://launch ) and include the url in the SMS, when the user launches that URL your application will launch.
I'm sure that is not the most straight forward way (since the SMS needs to include your custom URL) but I don't know if it is possible with any arbitrary SMS to launch an arbitrary applciation
do a google on iphone URL scheme and you will find lots of detail on how to implement this
here is an example
the below appdelegate method tells the full url that used to open your app
-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
//you could parse the url and take action according to that
}
The below app delegate method tells which app caused to open your app
- (BOOL)application:(UIApplication *)application openURL: (NSURL *)url sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
//you could capture the refered app custom url and open back from your app
return YES;
}
with following code snippet you could open the app that opened your app
NSURL *urlObj = [NSURL URLWithString:url];
[[UIApplication sharedApplication] openURL:urlObj];
Pass the custom app url.
It works fine. thanks hhafez!
I composed a SMS with url format "myapp://". It didn't work. Then I tried "", then it worked. thanks Brad!