Reputation: 4629
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.
Upvotes: 4
Views: 4179
Reputation: 32320
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.
Upvotes: 1
Reputation: 4629
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!
Upvotes: 0
Reputation: 170317
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.
Upvotes: 8
Reputation: 39810
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
Upvotes: 5