0

XCode 9 (currently in beta) has a method called activate that can be used to bring an application to the foreground: https://developer.apple.com/documentation/xctest/xcuiapplication/2873317-activate

Using the following code, I put the application into the background using the home button and then bring the application back to the foreground:

XCUIDevice.shared().press(XCUIDeviceButton.home)    
let app = XCUIApplication(bundleIdentifier:"com.aaa.abc.xyz")
app.activate()

When the application is brought to the foreground, the user is taken back to the login screen. It behaves as if it does not have access to the token anymore which the tokens are currently stored in NSUserdefaults. Does activate not check here for tokens or clear it?

Using app.launch() again does work but curious why activate() does not?

reutsey
  • 1,743
  • 1
  • 17
  • 36
  • You should debug your app to find out why it's logged out. Is it because your token from NSUserDefaults is empty or invalid? The documentation says:"If the application is launched as a result of calling this method and has previously been launched via launch() , the launch arguments and environment variables from the original call to launch() will be supplied again." So maybe you pass some arguments at initial launch() which clears your token from NSUserDefaults? – Michał Myśliwiec Aug 28 '17 at 14:58
  • Can you update your question to specify if you still have the issue with non-beta version of Xcode 9? – Cœur Mar 26 '18 at 08:30

0 Answers0