user784625
user784625

Reputation: 1938

How to detect an arrived sms message in IPhone?

How to detect an arrived SMS in code? and how can I auto check if it contains specific strings? for example I wanna send SMS to the Iphone which contains "specifString" and I want the receiver Iphone auto open my app.

Upvotes: 4

Views: 4035

Answers (2)

texmex5
texmex5

Reputation: 4344

You cannot, get a notification when a person receives a SMS, but you can enter a special url in that SMS that then would launch your application when clicked.

In your Info.plist you have to define some key-value pairs: enter image description here

And then your app is launched when url like this is clicked:

yourapp://?foo=1&bar=2

as you can see, you can pass parameters to your app.

In your app you get a special event, when your app is launched from an url.

4.1 and earlier:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 
{
  // Do something with the url here
}

**4.2 and later **

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation 
{
    // Do something with the url here
}

More details in documentation: "Implementing Custom URL Schemes"

Edit after WWDC Keynote 06.06.2011

New API iMessaging now supports messaging on iPad and also receipts to know if your message has been delivered.

Upvotes: 4

RK-
RK-

Reputation: 12201

You can not achieve what you are trying to do. Apple restricts this kind of things, because this amounts to spying on the user who uses your application.

Upvotes: 2

Related Questions