My app first notification disappears after few seconds itself when app is in background even when the user has not taken any action to that notification. After that every notification remains in place.
Does setting application badge number to 0 or cancelling local notifications has any effect on this.(I tried commenting those parts but it did not fix).
`func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?)
-> Bool {
Fabric.with([Crashlytics.self])
registerForPushNotifications(application)
application.registerForRemoteNotifications()
//Firebase push notification
FIRApp.configure()
// Add observer for InstanceID token refresh callback.
NSNotificationCenter.defaultCenter().addObserver(self,
selector: #selector(self.tokenRefreshNotification),
name: kFIRInstanceIDTokenRefreshNotification,
object: nil)
UIApplication.sharedApplication().applicationIconBadgeNumber = 0
}
}`
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
guard let aps = userInfo["aps"] as? [String: AnyObject] else{
return
}
let state = UIApplication.sharedApplication().applicationState
if state == .Background || state == .Inactive{
//do some background work
}
}
Any help would be greatly appreciated.