Show avaiable wifi connections nearby - ios

Can I display the list of wifi access points on UI dialog & allow user to switch wifi settings from within my app by using swift 3?
OR
Is it possible to open the wifi settings on a prompt dialog which does not cover full screen?

No. Check this answer.
It may help you
Objective C
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"prefs:root=WIFI"]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=WIFI"]];
} else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"App-Prefs:root=WIFI"]];
}
Swift
if UIApplication.shared.canOpenURL(URL(string: "prefs:root=WIFI")) {
UIApplication.shared.openURL(URL(string: "prefs:root=WIFI"))
}
else {
UIApplication.shared.openURL(URL(string: "App-Prefs:root=WIFI"))
}

Related

Open system settings to Add New Keyboard

I know it is possible to open up your app's own settings:
if (&UIApplicationOpenSettingsURLString != NULL) {
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
}
else {
// Present some dialog telling the user to open the settings app.
}
However, I need to open up a screen in the system settings. Specifically this one (the screen that contains the "Add New Keyboard" button, or even better, the screen right after that screen):
What do I need to do to implement this functionality in a button? (Answers in swift or objective-C are fine)

Why the app auto background refresh?

if ([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusAvailable) {
NSLog(#"Background updates are available for the app.");
}else if([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusDenied)
{
NSLog(#"The user explicitly disabled background behavior for this app or for the whole system.");
}else if([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusRestricted)
{
NSLog(#"Background updates are unavailable and the user cannot enable them again. For example, this status can occur when parental controls are in effect for the current user.");
}
And using this code to check the app status:
The app alway get into UIBackgroundRefreshStatusAvailable, and does not set any for "Background Modes" in capabilities(and info.plist).
Can anyone answer this, thanks.
The backgroundRefreshStatus property only mirror's device settings for the current user and is independent of the info.plist modes you set

how can I open a new application using [[UIApplication sharedApplication] openURL:] from a foreground app

I tried to open facebook app using this
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"fb://"]];
when my app is running in foreground , it works fine but if my app is in background it didn't work .
help me out .
I'm very new in programming
You are think impossible task. Think and first ask your self what are you trying.
Your app in to background it means (minimized). then where to trigger for calling open Facebook Native app method.
If app in background then you can't have any event for handle your app event from iPhone screen.
That bellow code for open Fb native app from app. but from background it out of logic think. that not relevant at all.
you can open facebook app using this bellow :-
- (IBAction)OpenFB: (id) sender
{
NSURL* facebookURL = [NSURL URLWithString: #"fb://profile/157893597658332"];
UIApplication* app = [ UIApplication sharedApplication ];
if( [ app canOpenURL: facebookAppURL ] ) {
[ app openURL: facebookAppURL ];
} else {
// url wrong
}
}
Here it is very nice Article
http://www.plungeinteractive.com/blog/2012/12/31/open-facebook-and-twitter-native-apps-from-your-ios-appgame/
UPDATE:-
I dont think this is suitable for your requirement but using Custom URL Scheme. you can able to Open your app from from safari browser or other app. just setting URL type--> setting URL schemes like bellow
and then try like i did in bellow image that open your app from browser:-
You cannot launch another app from the background mode because that would be pre-empting the user's current task without user interaction. There is only one application that is permitted to pre-empt the user's current action and that is the phone in the case of an incoming call.
What you could do is display a local notification and if the user actions that notification to launch your app - placing it back into foreground - then you could launch Facebook.
UILocalNotification* localNotification = [[UILocalNotificationalloc] init];
localNotification.fireDate = nil;
localNotification.alertBody = #"I want to launch Facebook";
localNotification.timeZone = nil;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
then in your app delegate -
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// Handle launching from a notification
UILocalNotification *locationNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (locationNotification) {
// Open Facebook
[application openURL:[NSURL URLWithString:#"fb://"];
}
return YES;
}
But if the user chooses not to action your notification there is nothing you can do.

Opening Phone app using button title

I have a UIButton with a telephone number as a title.
Will this code open the phone app with the title number?
- (IBAction)callContact:(id)sender
{
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:telfButton.titleLabel.text]];
}
It is giving me an error.
Depends what the URL is.
If its just 3033749943 it won't work. But tel://3033749943 will work just fine.
As stated in the other answer you have to use "tel://" to launch the phone app and dial the number. However, you can use NSString's stringWithFormat to add the number in the buttons title after "tel://".
- (IBAction)callContact:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"tel://%#",telfButton.titleLabel.text]];
}

Push Notifications Permissions

Trying to work around a few corner cases for when push notifications are denied in the app and I have two questions:
1) Is there a way to reset whether the user has seen the notification request pop up?
2) Is there any way to determine if the user has said no to the notification request?
1) No, unless there's some private API that does that, but that's not allowed by Apple
2) The first time your app is started, after calling registerForRemoteNotificationTypes, you can check if didRegisterForRemoteNotificationsWithDeviceToken is called. If it's not, the user said "No thanks".
You can always check the status of the permissions if the user changes them, you can check them on applicationDidBecomeActive
- (void)applicationDidBecomeActive:(UIApplication *)application
{
if ([[UIApplication sharedApplication] respondsToSelector:#selector(isRegisteredForRemoteNotifications)]) {
if ([[UIApplication sharedApplication] isRegisteredForRemoteNotifications]){
NSLog(#"Notifications Enabled ios 8");
} else {
NSLog(#"Notifications not Enabled ios 8");
}
} else {
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types & UIRemoteNotificationTypeAlert)
{
NSLog(#"Notifications Enabled");
}
else
{
NSLog(#"Notifications not Enabled");
}
}
}
updated to make it work on iOS 8 too

Resources