iOS push notification received when app is running in foreground

后端 未结 3 1665
旧时难觅i
旧时难觅i 2021-01-19 04:54

From my understanding, when app is running or in the foreground and a push notification is received, the app should NOT show any alert but the app delegate will call the

3条回答
  •  醉梦人生
    2021-01-19 05:37

    This answer is for swift users looking for the same thing

    let state = application.applicationState
    
            if (state == .active) {
                //app is in foreground
                //the push is in your control
            } else {
                //app is in background:
                //iOS is responsible for displaying push alerts, banner etc..
            }
    

    Please refer to the checked answer if you guys have any more doubts. Apple Documentation on handling Notifications

提交回复
热议问题