There is no direct solution for this as when the app is in background or locked the mobile ios prevent the app to run any tasks. To overcome this we need to do a simple trick by playing a silent audio which will keep our app active in background. Explanation added here: Medium Article.