GCKDiscoveryManager not founding Chromecast devices iOS SDK - ios

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

Related

iOS AVFoundation: Get AVCaptureDevice.Format's video dimensions

I'm trying to display the dimensions in which photos/video recordings can be taken to the user.
While photo dimensions are easily accessible through AVCaptureDevice.Format.highResolutionStillImageDimensions, I have no idea how I can achieve the same for videos.
I've tried the AVCaptureDevice.Format.formatDescription.dimensions property (or the .presentationDimensions(..) func), but those just gave me the following compile errors:
Since those are available since iOS 13.0 (I believe that was Swift 5.1?), I should definitely have the API for those (especially since I can CMD + Click on them in my code), and my project should compile. Am I missing something here? Is there a better solution to get the resolution a capture device can record videos in?
You just need below line.That's it.
let dimensions = CMVideoFormatDescriptionGetDimensions(format.formatDescription)
There is no direct API to get the video resolution.
You can set the AVCaptureSession.sessionPreset to one of the AVCaptureSession.Preset, then use canSetSessionPreset(_:) to check if the preset is supported by the current device.
I just did the following for testing and got all available video dimensions printed:
let descriptions = device.formats.map(\.formatDescription)
let sizes = descriptions.map(\.dimensions)
print(sizes)
I also checked if it compiled for iOS, Simulator, and macOS, and it does.
Are you still supporting iOS 12? Did you check your SDK setting?

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

How to perform UITesting on an app I don't have source code for?

I have been reading up on Apple's new and improved XCTest/UITesting frameworks and I have some questions as a Android developer. In android, to launch an app that I do not have the source code for to run UiAutomator I would simply use
#Before
public void setup() {
//Init UiDevice instance
Instrumentation mInstrumentation = InstrumentationRegistry.getInstrumentation();
mDevice = UiDevice.getInstance(mInstrumentation);
//start from home screen on each new test
mDevice.pressHome();
//wait for launcher
final String launcherPackage = mDevice.getLauncherPackageName();
assertThat(launcherPackage, notNullValue());
mDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), LAUNCH_TIMEOUT);
//launch app
Context mContext = InstrumentationRegistry.getContext();
final Intent intent = mContext.getPackageManager()
.getLaunchIntentForPackage(GMAIL_APP_PACKAGE);
//Clear any previous instances
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
mContext.startActivity(intent);
//wait for app to appear
mDevice.wait(Until.hasObject(By.pkg(GMAIL_APP_PACKAGE).depth(0)), LAUNCH_TIMEOUT);
mDevice.waitForWindowUpdate(null, 5000);
}
Using the above code, i am able to launch the package i want then use UiAutomatorView.bat to inspect the elements and get their resource id's (or find by text) then perform operations on them.
In iOS, all of the tutorials that i've found centre on testing apps that you have access to source code for. While I understand that it is much simpler to write these tests in iOS since you simply record the actions you wish to perform and xcode writes the code for you, I am unsure as to how to set the UI Test Target to an app that is currently installed on my device. I watched the WWDC video that went over multi-app testing using this:
var gmailApp: XCUIApplication!
gmailApp.launchArguments = "-StartFromCleanState", "YES"]
gmailApp.launch()
however this will not work since it has no target.
TL;DR: How do I set an app installed on my device, such as gmail, as my UI Test Target, and how do i discover package names in order to launch the app?
Thanks!
I don't believe this is possible unfortunately.
You only need the bundle identifier to launch another application.
https://developer.apple.com/documentation/xctest/xcuiapplication/2879415-initwithbundleidentifier?language=objc
I use this for macOS testing a lot so I guess it will work for iOS as well.

How to check if one of my app is installed in IOS device using corona sdk

How am I going to get a returned value that allows me to know whether my app was installed in IOS. In android, we can use "android.app.icon://my.package.name" by placing it in a display.newImage if it is not a nil value then I know one of my app was installed. We can't use that in an IOS device. I searched a link about using a url scheme
http://coronalabs.com/blog/2011/12/22/using-app-url-schemes-in-ios/
But the information was not that clear enough for me to understand and was not detailed at all. Is there another way to do it? I want to know the code. Thanks
The system.openURL() will return false if it can't open your app using a URL Scheme.

Cordova trying to dial telephone number

I am trying to dial a phone number in iOS, however I only have the simulator and an iPod Touch to test on.
The code uses something along the lines of:
window.location.href = 'tel:01234567890';
Working fine with Android, but in iOS it dies with:
Failed to load webpage with error: The URL can't be shown
Now, I do realise this has been asked before, but the general consensus from some time ago was "It doesn't work, you'll need to use a plugin". There haven't been many questions on this for some time though, and what questions there are seem to suggest it works when doing it programmatically (as above with window.location.href). I have tried the iOS PhoneDialer and the newer version of the same plugin, but both have errors in XCode (ARC forbids explicit message send of 'release') - a bit of faffing and I can get this running, but then PhoneGap doesn't find the plugin - it really feels like I'm hitting a brick wall with this method, and I can't believe something as simple as this requires something so over the top.
I know you cannot auto-dial/auto-call a number for security reasons, but all I need to do is open the dialer with number pre-populated, which is surely no different to a mailto:info#example.com link opening your email client with the sender pre-populated?
So, my questions are:
Has this changed with a recent update to PhoneGap, iOS or XCode?
Or, is it a case that I cannot do this on an iPod or Simulator, and it will work fine on an iPhone?
How can I fix it? :)
You didn't specify which version of Cordova you are using so I'm going to assume version > 3.
Make sure that InAppBrowser, a plugin since version 3, is installed and then open the link by calling it through Javascript like this:
window.open('tel:12345678', '_system')
_system will open it with the systems own browser which in turn will open the call dialog, if you use it against http://maps.apple.com/ it will open in the maps app and similar for other apps which opens for special urls.
Remarks:
As described in the docs of the InAppBrowser plugin the window.open function won't be set automatically. You have to do it your self: window.open = cordova.InAppBrowser.open;. Instead you can directly use cordova.InAppBrowser.open('tel:12345678', '_system');
Make sure your number doesn't have any blankspaces in it (the +
prefix is okay). For example you could use a function like the following,
assuming num is a string.
Function:
function placeCall(num) {
if (window.cordova) {
cordova.InAppBrowser.open('tel:' + num.replace(/\s/g,''), '_system');
}
}
Below Code works perfectly fine for iphone:-
window.open('tel:123456', '_system');
Simulator doesn't support dialer. No need to waste time.
Make sure that the phone number in your href also doesn't have any formatting in it, as on iOS it causes the link not to work in a PhoneGap App. So for example, use tel:0390005555, and not tel:(03) 9000 5555.
I don't believe this is a Cordova issue. I know in native iOS you cannot bring up the dialer on the simulator or on an iPod touch. You will need to test this on an actual iPhone.
I know this is a late answer time.
Try by adding // to the url. Like this tel://xxxxxxxxx and see if it works.
Worked for me in IOS 8.4, iPhone 6, 6+ as of today.

Resources