Connect to WiFi programmatically in ios - api

My question is about private API in IOS. Is there some API to manage WiFi connection? For example I'm using Apple80211.framework to scan WiFi networks but it's unusable for connecting.
My app isn't for appstore.

We can programmatically connect wifi networks after iOS 11 public API. You can connect wifi using SSID and password like following.
Swift
var configuration = NEHotspotConfiguration.init(ssid: "wifi name", passphrase: "wifi password", isWEP: false)
configuration.joinOnce = true
NEHotspotConfigurationManager.shared.apply(configuration) { (error) in
if error != nil {
//an error occurred
print(error?.localizedDescription)
}
else {
//success
}
}
Don't forget import NetworkExtension.

I ran into this issue last year and after quite a bit of digging I came across a helpful example called SOLStumbler. For this app to work your device must be jailbroken. I modified SOLStumbler and threw up a sample app on github. It uses the IPConfiguration bundle to access Apple80211 framework, which allows you to associate to a network. The readme contains the custom build instructions.
https://github.com/devinshively/wifiAssociate

No need for private API any more! With iOS 11, Apple provided a public API you can use to programmatically join a WiFi network without leaving your app.
The class you’ll need to use is called NEHotspotConfiguration.
To use it, you need to enable the Hotspot capability in your App Capabilities (Adding Capabilities). Quick working example :
NEHotspotConfiguration *configuration = [[NEHotspotConfiguration
alloc] initWithSSID:#“SSID”];
configuration.joinOnce = YES;
[[NEHotspotConfigurationManager sharedManager] applyConfiguration:configuration completionHandler:nil];
This will prompt the user to join the “SSID” WiFi network. It will stay connected to the WiFi until the user leaves the app.
This doesn't work with the simulator you need to run this code with an actual device to make it work.
More informations here :
https://developer.apple.com/documentation/networkextension/nehotspotconfiguration

It's possible in any version of iOS which can load a configuration profile: the app needs to generate a profile with the desired network credentials, and host a web server which provides the profile to Mobile Safari.

Related

How to install private apps using Android Management API?

I have made the application available to the organization in Google Play Store.
I am using Android Management API to install the application in the device. The public apps are getting installed but the private app is not getting installed.
I am getting the following nonComplianceDetails when calling https://androidmanagement.googleapis.com/v1/{parent=enterprises/*}/devices API
"nonComplianceDetails": [
{
"settingName": "applications",
"nonComplianceReason": "APP_NOT_INSTALLED",
"packageName": "com.xyz.abc",
"installationFailureReason": "IN_PROGRESS"
},
{
"settingName": "persistentPreferredActivities",
"nonComplianceReason": "APP_NOT_INSTALLED",
"packageName": "com.xyz.abc"
}
]
Am I missing something in the policy?
I am not able to view the app in the device play store. App is not getting installed also. And when I am giving installType as KIOSK a page is comming which shows 'Installing work apps'. And never gets installed. Also the app is approved in managed Play Store Enterprise.
Make sure that your private app is distributed properly to your enterprise. You can check this link on how to properly distribute your private app to an enterprise.
The non-compliance indicates that the installation is still in progress. This app could take a while to install depending on the size of the app and network connection speed.

IBM MobileFirst 8.0 WLAuthorizationManager.obtainAccessToken() No Response

I'm previewing the MobileFirst app (Cordova) on both browser and iOS Emulator but there doesn't seem to be any response when I call WLAuthorizationManager.obtainAccessToken().
I've tried to allow cross origin request but still face the same issue. Does anyone have any suggestions for what I should look at?
I had a similar issue on the iOS emulator. I even used Wireshark to see what was happening and the app never fired the authorisation request.
In the end I found that if you're running XCode 8.x, you have to enable keychain sharing by selecting the project -> Capabilities -> Keychain Sharing, and setting it to On.
After that I had to register the app again and all worked fine.
Make sure when you register or push the app and you're prompted for the version number, that you enter x.x.x instead of x.x - otherwise the server will not recognise the app.
Another thing to double check is the mfp:server runtime and url values in the config.xml file, if your pc's ip address has changed then the url value could be incorrect.

How do you test Apple Pay in Safari?

I am setting up Apple Pay on the web with Stripe and want to use the Sanbox Tester account we setup in iTunes Connect to test on both iOS and macOS in Safari.
On the test device (2017 iPad) I have logged in to iCloud with the Sandbox Tester account and added a test card into Wallet in the settings app. On my development website the Apple Pay button is showing up and interactions work fine.
I created a new account on my MacBook Pro (Retina, Mid 2015) and again logged in to iCloud with the same Sandbox Tester account. When I view my development website on here, however, the checkAvailability function always returns false:
Stripe.applePay.checkAvailability(function(available) {
alert(available);
...
}
Presumably this is because I need further setup for Apple Pay to work. But for the life of me I can't get macOS cooperate. After reading some documentation here are some points that I think are relevant:
In my iPad's Wallet & Apple Pay settings there isn't an "Allow payments on Mac" option anywhere
There is no Wallet & Payments option in my macOS Settings app
There is no mention of Apple Pay in macOS Safari settings, privacy tab
Handoff is enabled on the Mac
Is it possible for me to enable test payments with my sandbox user on macOS using handoff, and if so what steps am I missing?
Update
My macOS Sierra version is 10.12.4 (16E195)
Running window.ApplePaySession.canMakePayments() in the console returns false
Update 2
The steps outlined here are all in place on both devices. When I open Safari on the MacBook and navigate to a page, the handoff icon shows on the multi-tasking screen and vice-vera, when I open a tab in iOS Safari, the handoff icon shows to the left of the dock. It appears handoff is working as expected.
Also, Universal Clipboard is working in both directions.
Note: On a different (non-sandbox) iCloud account on this same MacBook, which is using handoff with a different iPad, the payment options show up in Safari as expected.
Apparently, Apple Pay on the Web using handoff is not possible with iPads. The only compatible devices are:
A Mac model introduced in 2012 or later with an Apple Pay-enabled
iPhone or Apple Watch
This comes directly from Apple. Pretty explicit details can be found on this page.
Edit from Leonardo: only iPhones and iWatches are supported to use ApplePay with handoff.
Looking at the source of the Stripe checkAvailability method might also help troubleshoot the problem.
Stripe.applePay.checkAvailability = function (callback) {
if (location.protocol !== 'https:') {
return callback(false);
}
var canMakePayments = window.ApplePaySession && ApplePaySession.canMakePayments()
if (/^pk_test_/.test(Stripe.key || Stripe.publishableKey)) {
callback(canMakePayments)
} else if (canMakePayments) {
var merchantId = "merchant." + window.location.hostname + ".stripe"
ApplePaySession.canMakePaymentsWithActiveCard(merchantId).then(callback)
} else {
callback(false)
}
}
Given you said that it was working with your iPad, I'm assuming your domain is already using ssl and the right cypher suite.
Since you are testing, the canMakePaymentsWithActiveCard shouldn't even been called since your stripe key should be a testing one, and if your look at the canMakePayments documentation , you can see they clearly stipulate that:
It does not verify whether or not the user has any provisioned cards in Wallet.
To make sure that your device is really supporting it, you should execute directly from your console
window.ApplePaySession.canMakePayments()
And make sure this returns true, if it does that means the issue belongs to the Stripe configuration rather than Apple Pay.
The other thing I see that could cause the problem would be the OS version of your mac. Your iPad is pretty new and thus will have the latest version already, but having bought your MacBook in 2015 does not necessary means you made the upgrade to Sierra (macOS 10.12) which is required to use ApplePay.
I'm sure you probably already tried all these things, I'm just making sure we didn't forgot anything.
Since HandOff seems to be required, make sure you also have all these requirements checked.

WatchOS 3 crash upon receiving push notification

i have an app that its configured to receive remote notifications. Before iOS 10 release everything was working fine on iOS and WatchOS side (push notification uses localised message and custom sound)
After release of iOS 10 and WatchOS 3 i had to add code that asks for push permissions using UserNotification framework (otherwise system will not provide push token, even tho old code isn't deprecated)
Worst of all if i have my watch app running when remote notification arrives - watches will reboot with apple logo. So push notification isn't crashing app itself, it crashes whole watch OS. Any ideas?
Have you checked your app capabilities and certificates are all OK?
I have a similar setup for one of my apps (using remote notifications), and I haven't needed to update the notification registration code to use the new UserNotification framework - it works as before on iOS10.
Xcode 8 is slightly different in how it tries to help manage your certificates and maybe something got messed up?
I was having the same issue, and the thing causing crash was "url" value of user info being null. I asked my back-end dev to make it just empty string and everything worked
Found a problem. Following payload causes Apple Watch to reboot
{
aps = {
alert = {
"loc-args" = (
Test,
"<null>",
Test,
4147
);
"loc-key" = "test";
};
category = "test";
sound = default;
};
}
If i replace "<null>" with " " - crash will go away

how to check network availablity in mobilefirst

I am developing an mobile application where I need to check if the device is connected to internet and if it is not connected then it should show an popup saying you are not connected to internet and it should have a option for settings on clicking which it should to take the settings of the mobile where the user can turn on the WIFI or mobile internet
There are two questions:
need to check if the device is connected to internet and if it is not
connected then it should show an popup saying you are not connected to
internet
You can use the WL.Device.getNetworkInfo API method, for example:
function wlCommonInit() {
WL.Device.getNetworkInfo(function (networkInfo) {
if (networkInfo.isNetworkConnected) {
alert ("connected");
} else {
alert ("not connected");
}
});
}
should have a option for settings on clicking which it should to take
the settings of the mobile device where the user can turn on the WIFI or
mobile internet
This could probably be implemented using a Cordova plug-in. Find a Cordova plug-in that allows you to open the settings screen of the device or even deeper, the settings > network setting screen of the device, there the user could do it. However, I would simply tell the user to go there on his own and not implement that... your choice, more complicated.