I have an option to print in my iPhone app.
On pressing the 'Print' button, UIPrintInteractionController is presented. The issue is that I want to show an alert on pressing the print button if no printers are connected.
I tried several options like [UIPrintInteractionController canPrintData:dataFromPath] but these options never worked.
From the docs:
if ([UIPrintInteractionController isPrintingAvailable]) {
//Printing is OK
}
else {
//Printing is not ok
}
Related
I tried this one. But, it Directly opens on the Google Maps application. The bottom sheet for choosing the preferred application is not showing. How do I achieve it? So, the user can select their preferred application.
This is my code for now,
try {
launchUrl(
Uri.parse("geo:${taskAddress.lat},${taskAddress.lng}"),
mode: LaunchMode.externalApplication,
);
} catch (e) {
} finally {
launchUrl(Uri.parse(
"google.navigation:q=${taskAddress.lat},${taskAddress.lng}&mode=d"));
}
I think you can't do that. It's user device preferred setting. If the user set it to "Always Open" or similar it will not ask again.
I'm creating snapshots using Fastlane. As my application uses "Push Notifications", when the app is launched it always displays to the user the pop up that requests the authorization to send this kind of messages. There is a method that is called in the AppDelegate UIApplication.shared.registerForRemoteNotifications(), this method is the one that "shows" the pop up to the user.
I have tried something like:
#if !DEBUG
UIApplication.shared.registerForRemoteNotifications()
#endif
#if TARGET_IPHONE_SIMULATOR
UIApplication.shared.registerForRemoteNotifications()
#endif
I also tried to set a Global variable but it hasn't been possible to find a place where to set this variable, because it never works
I always get the same behavior.
I would expect that the first time I run the test in the simulator, it does not display the message.
Thanks.
I found an easy way to avoid this screenshot.
Before the screenshot is taken, I simply press the button "Allow"
let systemAlerts = XCUIApplication(bundleIdentifier: "com.apple.springboard").alerts
if systemAlerts.buttons["Allow"].exists {
systemAlerts.buttons["Allow"].tap()
}
Simple an easy :)
I am am writing my XCUITests for my app, and currently struggling in finding the best solutions to dismiss my apps alerts. I have two sets of alerts, one is a notifications alert which pops up at the beginning of a fresh install, the second is a location alert when I navigate to the nearby tab on my app after a fresh install. I have tried using
let alert = app.alerts["\u{201c}VoucherCodes\u{201d} Would Like to Send You Notifcations"].collectionViews.buttons["OK"]
if alert.exists{
alert.tap()
}
but no success, I have also tried using a systemAlertMonitorTokenin my my setUp()
systemAlertMonitorToken = addUIInterruptionMonitorWithDescription(systemAlertHandlerDescription) { (alert) -> Bool in
if alert.buttons.matchingIdentifier("OK").count > 0 {
alert.buttons["OK"].tap()
return true
} else {
return false
}
}
Does anyone have any suggestions or point out where I am going wrong so I can fix this, thanks.
You might find these two questions and their answers to be illuminating:
Xcode 7 UI Testing: Dismiss Push and Location alerts
Xcode 7 UI Testing: how to dismiss a series of system alerts in code
How can I show a youtube or bits on the run video full screen on my app? Is there a special link I have to naviate to? Or is there a special API that takes care of that to view it fullscreen?
The idea is to click on a link 'show video', then show the video fullscreen, and get a button play pauze and 'done'. When clicked done it goes back to the previous page.
I don't know how to get started on this one. Can anyone help me out?
I'm creating an iPhone app.
Thanks!
#Muhammad has the first part right but to get it to close when you hit the blue done button you'll need the following code.
replace
win.add(activeMovie);
activeMovie.play();
with
win.add(activeMovie);
activeMovie.fullscreen = 1; // this must be defined after you add to the window!
activeMovie.play();
then add this
activeMovie.addEventListener('fullscreen', function(e) {
if(!e.entering) { // this is run only when exiting fullscreen aka the blue done button
activeMovie.stop();
}
});
Here is a an example code to show video with controlls
var win = Titanium.UI.currentWindow;
var contentURL = 'http://movies.apple.com/media/us/ipad/2010/tours/apple-ipad-video-us-20100127_r848-9cie.mov';
var activeMovie = Titanium.Media.createVideoPlayer({
contentURL: contentURL,
backgroundColor:'#111',
movieControlMode:Titanium.Media.VIDEO_CONTROL_DEFAULT,
scalingMode:Titanium.Media.VIDEO_SCALING_MODE_FILL
});
win.add(activeMovie);
activeMovie.play();
Hope this will help.
I have a UIWebView. In this, i want to catch when the user use the copy menu in order to copy selection into a pasteboard.
Afterwards when the user touch a button, the content will be paste in a mail.
I want to intercept when the user click on copy or cut menu. so i had this two methods :
- (void)cut:(id)sender
{
NSLog(#"cuuuuuuuuuut");
}
- (void)copy:(id)sender
{
NSLog(#"copyyy");
}
when i click on the cut menu, NSlog print cuuuuuuuuuut
but when i click on the copy menu , NSLog print nothing (copy method isn't called).
why ?
May I suggest UIPasteboard in the documentation? (Developer membership required)