apple push notifications - iOS UILocalNotification only makes a sound (no alert) when app is not running -


i'm using remote notifications wake app , conditionally trigger uilocalnotification.

i've found if notification triggered while app not running, notification sound (no alert/notification). works expected if app in background.

registering remote notifications in appdelegate:

let settings = uiusernotificationsettings(fortypes: (.badge | .sound | .alert), categories: nil) application.registerusernotificationsettings(settings) application.registerforremotenotifications() 

creating/firing of uilocalnotification (as result of didreceiveremotenotification)

var notification = uilocalnotification() notification.alerttitle = "my app" notification.alertbody = "hello world!" notification.soundname = uilocalnotificationdefaultsoundname uiapplication.sharedapplication().presentlocalnotificationnow(notification) 

as far can tell documentation, notification behavior when app in background , not running should same..

when system delivers local notification, several things can happen, depending on app state , type of notification. if app not frontmost , visible, system displays alert message, badges app, , plays sound—whatever specified in notification. if notification alert , user taps action button (or, if device locked, drags open action slider), app woken or launched.

source: uilocalnotification documentation

insight what's going on here appreciated!

the problem has nothing display of local notifications.

as said in question, use remote notifications trigger opening app , run code conditionally show local notification.

the reason why not working is:

your code show local notification not run remote notifications after user has force closed app (by swipe up)!

you can find more on in developer forums here: https://devforums.apple.com/message/873265#873265 (dev account login requiered)

also keep in mind if kill app app switcher (i.e. swiping kill app) os never relaunch app regardless of push notification or background fetch. in case user has manually relaunch app once , point forward background activities invoked.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -