swift - iOS Notification creating an Alert -


i'm creating ios-native app. i'm using xcode 8, testing on ios10, using swift 3.

i'm dealing apns , sending remote notifications (through onesignal).

the notifications work flawlessly outside app (when in background). however, when have app in foreground, no matter pass completionhandler() (ex. [.alert, .sound], or [.sound] or []) system creates uialertcontroller contents of notification (title , body) , presents user. incredibly obnoxious user-interface , imagine there way work around it.

i'm implementing unusernotificationcenterdelegate follows:

extension viewcontroller: unusernotificationcenterdelegate{ func usernotificationcenter(_ center: unusernotificationcenter, willpresent notification: unnotification, withcompletionhandler completionhandler: @escaping (unnotificationpresentationoptions) -> void) {       //this bryxbanner notification presentation/     let banner = banner(title: notification.request.content.title, subtitle: notification.request.content.body, image: nil, backgroundcolor: .blue, didtapblock: nil)     banner.alpha = 0.9     banner.animationduration = 0.2     banner.position = .top     banner.show(genview, duration: 3.0)       completionhandler([]) }  func usernotificationcenter(_ center: unusernotificationcenter, didreceive response: unnotificationresponse, withcompletionhandler completionhandler: @escaping () -> void) {         switch(response.actionidentifier){     //switch cases actions/     default: break     }     completionhandler([]) } } 

i'm implementing uiapplicationdelegate 1 has print statements.

what i'm seeing when receive notification this: screenshot of custom notification sent this

i've seen others have had issue (how disable default notification alert view on ios remote notifications?) have no idea how got around it. posts lead "oh, fixed it" no further explanation.

how can bypass showing of notification, whether silencing notification (if works) or dealing completion handler or intercepting notification before displayed?


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -