Sawant
Sawant

Reputation: 395

How to perform some action when app is closed by sending push notification in iPhone

I don't know whether i have to ask this question here or not, but i am really confused how to perform such thing.

I have to send sms via iphone, as i will receive push notification.

If my App is in foreground or in background i know how to do this, but if app is closed ie. not active then how i can perform such thing.

I don't want to prompt any message or alert.I just want to make it simple, As i send any message via push notification, my app receive it and perform the needful.

i can seen the api UIApplicationStateInactive. Is this api detect when app is closed, as after closing app i can't debug i don't know how it works.

If it is possible, please guide me how to do this.

Thanks.

Upvotes: 0

Views: 600

Answers (4)

Rohan
Rohan

Reputation: 2935

As Sandeep Sharma as suggested , you can use WebService to do as you wish.

Otherwise there is no any way to like that , because user must interact with your app to that thing.

You can launch your app as notification has arrived and can send the SMS after app has opened.

Upvotes: 0

iOS Rocks
iOS Rocks

Reputation: 176

i think you have to use web services to send the sms when user get the push notification . Once i used same

Upvotes: 1

Midhun MP
Midhun MP

Reputation: 107121

It is not possible AFAIK.

User need to interact with your app for performing some tasks when a notification is arrived. Else you can't do anything in a closed app.

Upvotes: 1

NANNAV
NANNAV

Reputation: 4901

your app will not active application: didReceiveRemoteNotification: is not working,when the app will launch from application: didFinishLaunchingWithOptions: that time we manually check notification like this

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
 UILocalNotification *localNotif =[launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
    if (localNotif) {

         }
}

Upvotes: 0

Related Questions