Removing iOS permission alert for local notifications when running app in simulator

后端 未结 2 1284
感动是毒
感动是毒 2021-02-05 11:55

I\'m trying to write an acceptance test in KIF on an app that asks for local notification permissions pretty early on. Unfortunately due to iOS simulator security reasons it isn

相关标签:
2条回答
  • 2021-02-05 12:39

    Unfortunately, I don't think in an automation test there is a good way to do this. I know that even resetting the simulator isn't sometimes enough to reset permissions. I would design your tests to not test a system call, but your own application code.

    One way to test different functionality based on whether the user allows notifications is to extract the call to check for permissions and then stub this method out in the testing. This method would be the best practice since the goal is not to test if iOS works but if your application code is correct.

    0 讨论(0)
  • 2021-02-05 12:43

    Notification permission can be suppressed by granting permission in applicationState.plist:

    • Run your app on a simulator and tap on "ok" for any permission popups
    • navigate to "~/Library/Developer/CoreSimulator/Devices/{$deviceId}/data/Library/BackBoard/applicationState.plist"
    • Replace the applicationState.plist of the UI test simulator with the above one before bootstrapping it
    0 讨论(0)
提交回复
热议问题