How to come Ios App to foreground from background - ios

I working on swift for Ios App. I want to phone user connect specific wifi. So i open iphone wifi settings by NSURL like this. After then my app go to background and i control ssid every 500ms in background by background task like this. When phone connect the specific wifi i can see this status and i stop background task. But i cant comes my app to foreground. I tried open my app use NSURL metod like this video (i add custom url my info.plist and add application function in my appdelagate) but my app has no return use this metod.

unfortunately bringing an app from background to foreground is not possible. You can however send a notification or a badge for the user to click and open the app. The user should have notifications enabled for this to work.
Happy Coding!

Related

swift: How to make a call when phone is locked or app in background

I have implemented Agora call in iOS app which works perfectly fine when app is in foreground ... Actually in my case we initiate call through Bluetooth BLE iBeacon. Along with this we call an API which is also working fine.
Problem is when app in background or when phone is locked ... Even when app is in background, app listens bluetooth event and Call API but it never start Agora call until we bring app to foreground. Means call works in foreground or it waits to start call when app enter in foreground.
To handle this I implemented local notification to prompt user to tap notification and bring app to foreground. But we want to do it through Bluetooth iBeacon. That instead of user to tap notification, it press beacon button to bring app in foreground and start call. On beacon button press I can catch the event in background as well but unable to bring the app to foreground.
Could not find some solution of it. But seems like its do-able as with Car tablets which are connected with bluetooth to phone we can dial a number on tablet and through bluetooth communication with phone it makes a call to selected or dial number even when phone is locked.
Means third party bluetooth devices can send command to locked phone and initiate call.
There are two ways using that you can make calls when app is in background or in locked state even your app is in killed state.
Using CallKit Framework provided by apple.
You can send custom push notification to the user and on click of push notification application is wake up and call is happen.

How to show notification in iWatch?

In my app, I want to implement functionality like when iPhone away with some distance from iWatch than watch app show local notification with a text message
If it is enough for you to get notified when the Watch gets disconnected from the Phone, you could use the WatchConnectivity framework to achieve this.
The optional func sessionReachabilityDidChange(_:) gets called on the Watch when it disconnects from the Phone.
However, your WatchExtension needs to be running in the foreground or with high priority in the background for this function to work.

How to bring IOS app from background to foreground without using local notification?

Is there any way to bring the app to foreground which is running in background without sending any local notification?
There is no way for you to programatically foreground the app. If you think about it, allowing developers to do that could have significant consequences to user experience.
There must be a way to simulate it.
Uber Driver's App launch when the user gets a new ride with app in background.
WhatsApp in background opens a phone view when somebody calls the user.

ios play continues sound when app receive push notification

Currently i am working on app in which i want to play continues sound when app receives push notification. as i know apple allow to play custom sound of length of 30 sec here is link..
but in well known app it plays continues sound in driver side when app is in back ground and driver receives order.
and another issue is of when my app is in back ground and receives push notification Rather clicking on notification if i open app by pressing app icon it does not show me data of push. it is not possible to load data when press on app icon here is link
iOS Push notification issue
but same thing is done in well known app
With iOS 7+, use application:didReceiveRemoteNotification:fetchCompletionHandler:, which is called even if your app is in the background. iOS will even launch your app in the background if it's not already running, but if the user force quits the app, it will not be re-launched. If you enable the remote-notification background mode, you can run app code when the notification arrives. If you include the audio background mode, you could initiate a sound that continues to play while app is in background.
For second question, typically, your app should query a server for updates if it's launched directly. However, you could leverage a remote notification as above, which you'd get in most cases (except if the app were force quit).

iOS background service vibrate phone

I have an app that runs in the background (location services). When the app is in the foreground it vibrates fine when I want it to, however, if its not in the foreground (in the multitasking view), the vibrate does not work anymore. Is this not allowed? Is there some way for my background app to give a vibrate alert? If not that what about a beeping sound?
Right now I am just doing something like this:
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
While importing:
#import <AudioToolbox/AudioServices.h>
If you enable background audio modes (as documented by Apple at https://developer.apple.com/library/prerelease/ios//qa/qa1668/_index.html) then vibration will happen when the app is in the background state. I just verified that adding the "App plays audio or streams audio/video using AirPlay" entry under the "Required background modes" property in the target's properties allows the vibration to work when the app is not in the foreground.
I found that checking 'Audio,AirPlay and Picture in Picture' within the 'Background Modes' of your apps Capabilities worked:
If you're trying to provide the user with a notification of something while your app is running in the background, consider delivering that information using a Local Notification (see UILocalNotification.)
Forcing the phone to vibrate is not a great user experience for a few reasons:
Some users (including myself) disable vibrate while in silent mode
iPads and iPod Touches do not vibrate
Users may not know what caused the vibration or sound and may not realize to open your app
Local notifications appear to the user in a manner that they can control and will recognize.
If your intention is something besides notifying the user, add that to your question & I'll try to help.
I'm pretty sure that you aren't able to vibrate the phone while it is in the background state. I've actually never seen an app do this.

Resources