iOS local notification only when the screen is locked and without screen activation ? - ios

Got 2 questions for the xcode experts :
- I would like to send a (repeating) local notification only to the locked screen but without having the screen turning on, it is possible ?
- I also would like to check whether the screen is on or off (for this very purpose) : is there any way with the current IOS version (IOS 7) ?
Many thanks for any help !

No this is not possible, frits it will be very hard to get you app running in background without misusing one of the background modes.
You cannot detect if the devices is locked and you will flood the notification center with messages.
If you do manage to get it working then there is good chance that Appel will reject your app for doing this.

You can check the screen by checking the applicationState property, which will be set to UIApplicationStateInactive when the phone is set to lock/sleep (as opposed to UIApplicationStateBackground).
As for the notification, you can set a push notification delegate (I've not done it from scratch, but I did it using Urban Airship and creating my own custom push handler class) and handle whether to post an alert or not there. I'm not sure, though, whether having the phone sleep will kick notifications to the OS level, which would default to showing a notification on the screen.

Related

Actionable push notification isn't appearing on device with iOS 8+, when user force quit app by swiping-up

I am using ONE SIGNAL for push notification
ONE SIGNAL is providing functionality of actionable push by adding "actionButtons" key including in payload.
{"actionButtons" = {"id":"1","text":"Confirm","icon":""},{"id":"2","text":"Cancel","icon":""}, "actionSelected" = "1"}
So whenever push notification will appear on device, it will appear with two buttons "Confirm" and "Cancel" and based on user's selection 'id' of the button will be stored in "actionSelected" key.
Everything above is working perfectly whenever app is in either in foreground or in background in iOS 8+
But when user force quit application (swipe-up) notification isn't appearing on device.
I have also added "Remote Notifications" in background modes, all certificate is also set perfect. I don't know what am i missing.
If anyone got any idea about this issue then kindly help.
All suggestions are welcomed. Thanks in advance.
This is a limitation related to how OneSignal handles action buttons. OneSignal uses the content-available flag as part of a technique to support custom text on action buttons and this flag is ignored in cases where the application has been force-closed.
When force quitting any iOS app, that device becomes ineligible for notifications for that specific app until that app is ran again. So if you're testing open the app, and then close it (put in background).

iOS local notification without turning on screen

I'm working on app that will manage quite a lot of local notifications. So since I don't want to waste user's battery, I'm wondering - is there any possibility to don't turn on the screen? So the notification still will be fired and the banner will be on the screen but only if user will unlock the phone. It's kind of "minor notification" that are still should be displayed but they're not so important to wake up the phone.
And if there's such possibility - wouldn't it be what Apple calls "bad user experience". You know, kind of confusion that notification didn't wake up the phone's screen?
And yes, sound still should exist, because it should work as reminder.
Thanks in advance.

iOS Local notifications from a background running app

I'm looking for a way to send local notifications on the user device (with a pop-up) from my app running in background (with the location background execution mode which allow to keep running always).
In fact, this app have to check battery level and send local notifications when a certain level is reached.
I have some questions about it that I didn't found answers on the net because of the specificity of this app :
Where can I put my battery level checking method ? I know that the app can keep running with background execution mode but I don't know where to put the test and if I have to do an "if" statement or a notification center observer ?
I tried to put an "if" statement in the location update method (wrong place I guess), and when the app is in background and the battery level reached the level I'm wanting for, there is a notification displayed in the notification center, but there isn't pop-up displayed on the top of the screen, so the user have to go manually in the notification center to see it.
I hope to be understandable, thanks for your futur answers and have a nice day.

Questions about Local notifications in iOS

I'm working on a project on iOS 7, 8 that use a lot of notifications (Remote, Local). I have some questions about Local Notification.
I'm using Local Notification to schedule an alarm or a count-down. As I know, the use of NSTimer is not really a good choice since it has only up to 10' in background & if the app process is killed it doesn't work anymore. Local Notification is managed by iOS but I have to accept its alert when the app is not in foreground. There's nothing like silent local notification (local notification without alert, sound or badge and app still knows about it although it's in background). Am I right ?
Let's assume that there're some simple local notifications in Notification Center, scheduled by our app. Normally when I touch on a notification to see it in my app, the others remain present until we interact with them. In some cases that I haven't figured out, all other notifications are removed from the Notification Center. Does anyone encounter this & understand why ?
I find the interactive notification feature in iOS very limited. I want to change the title of a defined UIMutableUserNotificationAction button & add an image for it, like I can do with UIButton. So the question is : Is it possible to customize the UI of an action button ?
Thanks for your help !
Unfortunately there is no correspondence in silent notification using local notifications.
The number of the visible notification in the notification center is a user decision, the user in Settings can decide to set a different number or decide to do not show them in notification center as well. As for the first point no. The third point is not clear, you can set the image you want for a remote just put in the payload the right name, local notifications use the app icon.
There is no silent notification for Local Notification. The user has to click to the notification to open your App.
I suppose that the associated application has deleted those notifications programmatically. Else, those notifications must stay in the notification center.
You cannot add image to action buttons but just the titles.
I tried more than two weeks to do the same. I had to show notification after 2 hrs even if the use doesn't click the notification. But the repetition facility is well handled in objective C. I could have created multiple local notification but it will also violates the total number of 64 notifications. Apple needs to improved the same.

Custom notification when app in background or close

Is it possible to create an notification when my app in background all close.
What I mean:
If my app goes to background at some point at time I want to get notification with alert view on main screen in iPhone.
Alert view have to contain my custom description text.
Is it possible? and if this is possible that wich verion iOS should provide this option.
Thanks!
Yes, you can use a local notification.
https://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction/Introduction.html
Local notifications were introduced in iOS 4.0

Resources