Notification count showing when application is installed in iOS - ios

When application is installed for the first time I am seeing notification badge count as 1 by default. I am not able to find from where it is coming.
I tried many approaches provided over SO, but none of them worked for me.

Add this code in your AppDelegate.m
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];

Related

I can't fetch data in background in iOS

My app does the intended operations when I use Simulate Background Fetch in the Debug tab in Xcode, however, when the app is running on my phone nothing works.
Has this happened to someone before? How did you resolve it?
I'm currently using Swift 2.2 and Xcode 7.3
Did you edit the schema in Run mode for the Launch due to a Background Fetch Event
iOS Background Fetch Not Working Even Though Correct Background Mode Configured
iOS won't allow any app to run in the background unless the app ask for it and it will allow it to run for 10mins only to register for background execution:
- (void)applicationDidEnterBackground:(UIApplication *)application {
UIBackgroundTaskIdentifier identifier;
identifier = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
[[UIApplication sharedApplication] endBackgroundTask:identifier];
}];
}

iOS 9.2.1, cancel notifcation not working

I'm developing an app having local notification scheduled.
I'm not able to cancel the scheduled notification using the code:
UIApplication *app=[UIApplication sharedApplication];
[app cancelLocalNotification:notification];
The code is working well in previous iOS versions, but it is stopped working in iOS 9.2.1 update.
Can anyone please help me to sort out the issue?
There is a bug in iOS 9.2.1, so cancelLocalNotification methods doesn't work sometimes.
Use cancelLocalAllNotifications and update your logic accordingly.
This should work.
Keep your localnotification object in NSUSerDefault when it is scheduling, even if your device gets restart you can retrieve localnotification object from NSUSerDefault. So then after you can easily pass that object in cancelLocalNotification(localNotificationObject) and remove it.

Cant cancel all local notifications in iOS9

When i have multiple local notifications and i try to cancel them with :
[[UIApplication sharedApplication] cancelAllLocalNotifications];
I keep getting them anyway . i have read there is some bug about it in Xcode 7, and i couldn't find solution for this .
https://forums.developer.apple.com/thread/9226
How can we launch if we cant cancel notifications ?

ApplicationIconBadgeNumber is not getting reset on reinstallation of my ipad app.

I'm setting my applicationIconBadgeNumber using this code:
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:theIntToDisplay];
The problem is that when I delete the app from an iPad and reinstall it, the app icon still shows the previous badge number. Is this default iOS behavior or can we reset it?
I found one similar question on at Why the applicationIconBadgeNumber is not getting deleted with appliccation ? Where it stored actually?, but it didn't answer my question.
This is an expected behavior, the badge number remains for a short period after uninstall e.g for the case of an immediate re-install.
Of course you can nullify badge number after every launching the application in application:didFinishLaunchingWithOptions: method but I think it is not the case because you want badge number not to be shown right after you install app and not yet launch it. In such a case just wait after removing the application and the badge numbers cache will be cleared by iOS and then install the app again. Unfortunately without jailbreaking the device there is no way to manage badge numbers behavior manually
In your app delegate under:
- (void)applicationWillEnterForeground:(UIApplication *)application
{
}
Insert:
application.applicationIconBadgeNumber = 0;

UIApplication icon badge number remains at re-install [duplicate]

This question already has answers here:
Badge count is persisted after deleting an app and installing it again
(4 answers)
Closed 5 years ago.
The UIApplication badge number is not deleted at reinstall.
In case I uninstall the application when the badge has a non zero value, and then re-install it, the badge still appears in the new installation.
I update the badge number in the following manner:
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:badgeNumber];
Tried to find a solution - some notification when the application terminates so I can remove the badge... Couldn't make it with applicationWillTerminate. Any suggestions?
Apple actually responded and this is the expected behavior, the badge remains for a short period after uninstall (exactly for the case of an immediate re-install).
Try to set:
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:-1];
in application: didFinishLaunchingWithOptions:
Worked fine for me.

Resources