Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift Use of unresolved identifier 'UIApplicationStateInactive'

In my Swift code to handle push notification I have this line:

if ( application.applicationState == UIApplicationStateInactive  || application.applicationState == UIApplicationStateBackground) {
}

Which cause the compilation error: Use of unresolved identifier 'UIApplicationStateInactive'

Am I missing some import files?

Thanks

like image 507
Ray Avatar asked Dec 02 '22 17:12

Ray


1 Answers

Currently your are using the identifiers for Objective-C. You need to use the identifier for swift:

UIApplicationState.Inactive // equals UIApplicationStateInactive
UIApplicationState.Background // equals UIApplicationStateBackground

Apple documentation for:

  • Swift
  • Objective-C

You can check the documentation for both languages in the Apple Documentation and choose the language in the top right corner.

like image 114
Christian Avatar answered Dec 20 '22 07:12

Christian