Swift Use of unresolved identifier 'UIApplicat

2019-04-09 18:07发布

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

1条回答
Juvenile、少年°
2楼-- · 2019-04-09 18:19

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:

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

查看更多
登录 后发表回答