How to disable application badge completely using iOS SDK - ios

The user can disable an app from showing the badges from push notifications. How can this be done pragmatically? So far I have only found solutions where the badges are cleared when an app comes to the foreground. I am looking for a solution that would work regardless of whether the app is in the foreground, background or not launched at all.
I tried setting applicationIconBadgeNumber = 0 in appDidFinishLaunching and that didn't work.

Did you try it in applicationDidBecomeActive?. If the app is running in the background, appDidFinishLaunching will not be called

Related

Can I disable a particular local notification banner when app is in foreground?

My application is currently set up to display local and push notifications even when in the foreground. There is one specific local notification I would like to disable when in the foreground, but keep enabled when the app is not active or in the background. Is there a way to accomplish this?
When app in foreground iOS will not show notification banner/alert by default on its own, you must have written code or used a third party frameworks to show some banner on App, just put a break point in that code to not to show the specific notification
https://github.com/nhdang103/HDNotificationView

How to bring IOS app from background to foreground without using local notification?

Is there any way to bring the app to foreground which is running in background without sending any local notification?
There is no way for you to programatically foreground the app. If you think about it, allowing developers to do that could have significant consequences to user experience.
There must be a way to simulate it.
Uber Driver's App launch when the user gets a new ride with app in background.
WhatsApp in background opens a phone view when somebody calls the user.

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).

UIApplicationState of app is inactive after following interactive push notification when app is closed

App is not running. Interactive push notification comes in. User taps a button on it. App is launched, notification action is handled, but app state is still inactive. Even when I background/foreground the app, it's still inactive. If I follow the notification directly (tapping the notification, not the interactive button) from the same notification, the app gets launched and is in active state. Why doesn't it always go to active state?
Have some thoughts on this.
First of all, it's not a given that a notification will result in a user opening up the app.
Second, there are notification callbacks in the delegate. Is it possible to manually set the application state?
If not, and I don't want to jump to conclusions, but this sounds like it may be a bug, and you may want to file a radar.
Although, you may be able to work around it. Look at those delegate methods.

How to change the application state to foreground when it is in background

I want to programmatically invoke my running application which is currently in background state.
I know it can be done by local notification but is there any other way, any suggestion would be helpful.
Well YES in a way. You can simply implement push notifications for your app wherein there will be a notification displayed from the top of your device . On clicking this notification, the app will open accordingly. This is done by default. I hope this is what you were asking. Otherwise, there is NO other way to get your app from the background to the foreground state without clicking the icon of the app.
No, there is not a such a way.
As far as my knowledge directly we can't change app state from background to foreground programmatically. There are no other methods available other than Notifications.

Resources