0

I have used push notifications in my app. And I have two questions regarding this:

  1. My app does not launches automatically when the phone is in standby mode and it receives push notification.Contradiction is that when the app in standby and in quickly unlock it by swapping it launches the app but when I swap later say after 2-3 min then the app does not launches automatically. How to make it possible to launch every time?

  2. I want to increase the vibration time during push notification. Currently it hardly vibrate for 1 sec.

halfer
  • 19,824
  • 17
  • 99
  • 186
Himanshu Mohan
  • 722
  • 9
  • 30

1 Answers1

0

1) The concept of asleep/standby is not too tricky; when the user 'quits' your application (pressing the home button), your application will either be halted and placed into a frozen state (4.x), or quit entirely (3.x). Nonetheless, you are given the opportunity to do a few cleanup operations before the latter happens with the - (void)applicationWillTerminate:(UIApplication *)application method, and before the former happens with the - (void)applicationDidEnterBackground:(UIApplication *)application method (both are called upon your delegate class). The concept of 'sleep' means that in both iPhone OS 3 and iOS 4 you'll receive the following method when your app loses focus (and also when an SMS comes in, or an alert, etc):

- (void)applicationWillResignActive:(UIApplication *)application

Really, most applications (with the exceptions of applications that are designed to work in the background, like voip, audio streaming, etc) simply quit on close. But if you need to, you can also suspend the freezing of your app and ask for more time to complete a task.

2) You cannot change vibration duration with official APIs.

You could call AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); multiple times in a loop or using a NSTimer, but that is not recommended. It drains battery and the device could fall off the table. By the way, Apple could reject your app if they consider you don't use the vibrate properly.

Srikar Appalaraju
  • 71,928
  • 54
  • 216
  • 264
  • Thanks for your answer.In respose to your answer of point 1, how can i ask for more time to complete a task?. Also app may receive notifications any time irrespective of when the app enters background so if i ask for more time then for how much time i ask...as it is unknown to me.. – Himanshu Mohan Feb 14 '12 at 06:42
  • apple docs say after the app is quit by the user, the app is given 10 minutes to complete any pending tasks. After which all resources will be suspended for that app. Check here for more - http://stackoverflow.com/questions/8861390/ios-background-downloads-when-the-app-is-not-active – Srikar Appalaraju Feb 14 '12 at 06:50
  • Ok.But i just simply want to know can i make my app launch in every condition of push notification(i.e. sweep screen immediately and sweep screen after some time of notification). My app is just all about "time to do some task"(this task is configured locally as alarm and i m using push notifications aa alarm).....pls help – Himanshu Mohan Feb 15 '12 at 05:55