0

I need to schedule a UILocalNotification when battery is n percent. UILocalNotification has fireDate property only and UIApplication class has below methods for presenting local notifications.

 - (void)presentLocalNotificationNow:(UILocalNotification *)notification;

- (void)scheduleLocalNotification:(UILocalNotification *)notification;

Is they are anything else that would help me post local notifications based on events and not time. I can do it when the app is in active or background state. But I want to schedule it, so even if app is terminated, it can post the notification.

Sikander
  • 447
  • 4
  • 26

1 Answers1

0

No, your app needs to be running in order to schedule a local notification.

In order to do what you want you would need some way to launch your app when the battery level reaches a specified level, and I don't think that's possible.

Duncan C
  • 128,072
  • 22
  • 173
  • 272
  • Can I make the app to run in background forever ? I'm thinking of sharing battery status with server and then send push notification when battery is n percent. – Sikander Apr 05 '16 at 21:26
  • It's tricky but possible, although Apple would reject any app that did that. Plus no customer would want it even if Apple allowed it. (Running an app constantly drains the user's battery quite quickly since it keeps the CPU in a high power mode.) – Duncan C Apr 05 '16 at 23:08