webview is loading in simulator but not loading in device - ios

I tried to load UIWebView in swift so far am able to call and load webservices without any problem , both webview and json services in simulator.
But when I tried load it in device all the other webservices are working except UIWebView.
let url = "http://192.168.1.233/PhpProject1/MoreDetails.php?id=1234"
UIWebView.loadRequest(webView)(NSURLRequest(URL: NSURL(string: url)!))
I checked the log but nothing happens after calling the UIWebView in the device.
The problem is that only webview is not loading in device, I am able to call all other webservices, and everything is working fine in emulator.

From ios 9 apple introduced NSAppTransportSecurity means you can't hit http server from your device. So you have to use url with https. But still you can hit http by adding exception in info.plist. For that you can see this link
How can I add NSAppTransportSecurity to my info.plist file?.
And as said by others always use reachability class to check wether the server is reachable or not :)

192.168.1 seems a private LAN , probably reachable by your MAC PC through the wired cable (ethernet cable). If you have your iPhone connected throught WIFI probably it's not the same lan, or WIFI cannot reach the 192.168.1.x. Check your connections.
Apple provides reachability classes you can use the class to check if Reachability(hostname: <your host>) is true or not for both devices (PC and iPhone). You can also look the swift translated reachability here in gitHub, there are many examples to how to do it.

Related

React native ios deeplinking with universal URL

I've been facing issue setting up deeplinking with react native for IOS with react navigation 5.
When i try the URL scheme of myownapp://homepage/ it opens up the app.
But if i try with url : https://dev.myownapp.com/homepage/ it opens up the safari browser, but it doesnt open up the app.
I've tried with the documentation by adding Appropriate code in AppDelegate.m file and also ive added myownapp.com in the Associated Domains in Xcode.
Can you guys brief about what configuration is left to be done because the same opens in android. Thanks in Advance
Can you reach https://dev.myownapp.com/.well-known/apple-app-site-association or https://dev.myownapp.com/apple-app-site-association yet?
If you can't, please host the file on the servers you want to be supported universal link.
So to make it work:
You need to setup your app to be supported wildcard domain by set applinks:*.myownapp.com.
You also need to host the config file (apple-app-site-association) to all the sub-domains, it means you're able to reach:
https://sub1.myownapp.com/.well-known/apple-app-site-association
https://sub2.myownapp.com/.well-known/apple-app-site-association
....
Another thing you should notice that all your domains must be supported secure connection (https).

is it possible to turn off wifi or switch iPhone to offline mode in codes in swift 4?

I want to know is there any way to turn on or off the iPhone wifi or switch the device to offline mode in codes in swift 4 or not
I know that apple may not allow the app can do such things to be distributed in App Store But it's Not important I just want to know is there any codes to do that or not (Just in swift 4)
5 Solutions Collect From Internet About “How to turn off internet connection, bluetooth and WIFI programmatically?”
Ans
You can’t. Apple does not allow 3rd party apps to change global system settings like that.
There is no API available to control cellular data,wi-fi,bluetooth within in an app , User have to go to settings to enable or disable cellular data,wi-fi and bluetooth.
This is not possible in iOS unless you jailbroke your device. Apple is not allowing any apps developer to access wifi/bluetooth. You can only check wifi/tooth is connected or not.
You can’t do that using the iOS application. Apple not allowing it.
Legally there is no way to do it. Even somehow if you are manage to do it, Apple will reject your app while submitting to AppStore.
update
I am not sure the following code will work or not, try once, initially add the header file to your project folder and create the bridging header to your code ,then use the below code where you need , for ref purpose I taken the answer from here
var tempSBWifiManager: SBWiFiManager = objc_getClass("SBWiFiManager")
// Steal a class from SpringBoard
tempSBWifiManager.sharedInstance().isWiFiEnabled = false

iOS swift check if URL accessed via ipv6

Is there a way to check if a website is ipv6 compatible before loading it to a webview via url request?
I am asking this because I want to publish an app thats main layout loads a webview first and the url it loads isnt ipv6 compatible. Now its giving off a white screen due to which apple is rejecting my app from being published. Now that solution I want to apply is:
if(connection is ipv6) {
//do something to prevent loading the webview
} else {
//load the webview normally
}
but this is my first time using xCode and SWIFT, even MAC just installed it on vmware workstation.
edit : extra information, the application is just a single layout that has a webview to load a mobile friendly website nothing more than that:
webView.loadRequest(URLRequest(URL: URL(string: "link")!))
the review guy from apple:
From Apple
Performance - 2.1
We discovered one or more bugs in your app when reviewed on iPad
running iOS 10.2.1 on Wi-Fi connected to an IPv6 network.
Specifically, your app launches to empty white screen.
Please see attached screenshots for details.
and the screenshot is just a blank white image

GCKDiscoveryManager not founding Chromecast devices iOS SDK

I'm trying to find Chromecast devices with my iOS App.
I've downloaded cast SDK via CocoaPods, and then I try the following:
let gckCastOptions = GCKCastOptions(receiverApplicationID: kGoogleCastAppReceiverId)
GCKCastContext.setSharedInstanceWithOptions(gckCastOptions)
GCKLogger.sharedInstance().delegate = self
self.discoveryManager = GCKCastContext.sharedInstance().discoveryManager
self.discoveryManager!.addListener(self)
self.discoveryManager!.passiveScan = true
self.discoveryManager!.startDiscovery()
And then, in the listener method:
func didStartDiscoveryForDeviceCategory(deviceCategory: String) {
print("GCKDiscoveryManagerListener: \(deviceCategory)")
print("FOUND: \(self.discoveryManager!.hasDiscoveredDevices)")
}
Result is always false :(
On my Mac, when I open YouTube, I can stream video to Chromecast device, so device is set definitely.
I am testing on simulator? Should I try it on real device? I suppose that this is not necessary since I'm only trying to discover the available devices.
I've tried to add GCKDeviceScanner too, no luck. I suppose that this is the starting point.
Tried to add GCKUICastButton via storyboard - not being able to do it :(
Have a look to this setting. As soon as I enabled it it started working
Also, please make sure you set another kReceiverAppID other than the given example (AABBCCDD), for example we are using the one listed on the example app, for example static NSString *const kReceiverAppID = #"4F8B3483" (I guess you need to make your own at Google Play Developer Console)
And finally, you can be pretty sure it will never work on a simulator, you need REAL device for this.
Have a look in this setting. Go to project capabilities
Go to project setting and select device capabilities. select this option as discussed in image

How to use UIWebView that supports IPv6?

I have an app that shows a content using UIWebView. Apple rejects the app, because it doesn't support IPv6 network. Do you have any idea how to fix that? I have to import some libraries or do something else?
I am not using IP address for the URL, but it's domain name, for example:
https://asd.com
Your UIWebView not the reason of rejection the reason was your link or you server not support IPV6, Firstly test if your link support ipv6 that apple mean from this link you can do it , If you not pass this test search for how to configuration your server to support IPV6, I hope I help you
If your application is targeting above iOS 8, try using WebKit instead of UIWebView.
Refer to the following link which clarifies the text below it:
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebView_Class/
Note: "In apps that run in iOS 8 and later, use the WKWebView class instead of using UIWebView. Additionally, consider setting the WKPreferences property javaScriptEnabled to false if you render files that are not supposed to run JavaScript."

Resources