I'm writing a UI Automation test script and I have noticed that the onAlert function that is supposed to be called by the test script automatically every time there is a alert presented to the user is not getting called.
To test this I have a simple UIALogger.logMessage() call just logging a message that the onAlert method was entered.
Any ideas on why this is happening?
I found out that if execution of the test script reaches the end and an alert pops up, the onAlert handling function is no longer triggered even though the test session is still running and logging diagnostics.
Related
I'm implementing GADRewardedInterstitialAd into a game.
https://developers.google.com/admob/ios/api/reference/Classes/GADRewardedInterstitialAd
I'm using presentFromRootViewController:userDidEarnRewardHandler to react to the user finishing the ad.
Now I'd also like to know how to react to the user cancelling the ad.
If I continue directly after calling presentFromRootViewController, the callback handler will not have been called yet, because the systems works asynchonous, as is to be expected. So any game animations (e.g. screen fade, dialog close) will have to be stalled.
If I rely only on the handler, I won't get a callback when the ad was cancelled.
My solution would be to build in a timer that waits 30+1s to give the handler a chance to get called (hopefully on the next main thread dispatch cycle), and then react to it not being called yet (assuming a cancellation by the user).
I really hate that plan.
It's not deterministic.
It doesn't use callbacks/delegates/handlers (which are great exactly for this kind of thing)
I have to write the timer code and keep a boolean flag somewhere... it's messy.
It adds an arbitrary delay to the user experience (30+1s) when they close the ad!!
Am I thinking the wrong way about this or is this just the way Google has made it and I'll have to live with it?
Edit: please note that I'm talking about the new GADRewardedInterstitialAd API, not GADRewardedAd.
I've figured it out; it works by setting GADFullScreenContentDelegate fullScreenContentDelegate and implementing adDidDismissFullScreenContent.
In there you can check if this particular instance of GADRewardedInterstitialAd did not get a reward yet (as notified by userDidEarnRewardHandler...)
This all hinges on the assertion that adDidDismissFullScreenContent gets called AFTER the userDidEarnRewardHandler, else I will already have assumed there was no reward. Let's hope that is always the case.
https://developers.google.com/ad-manager/mobile-ads-sdk/ios/api/reference/Protocols/GADFullScreenContentDelegate
I'm debugging a project and I noticed that only some of my breakpoints get triggered.
In my screenshot you can see I have 4 breakpoints. The first 2 get triggered when the program runs. I'm sure the code in the loginButtonPressed function gets called. I've proof of this printed on the console. The string "creating account" gets printed.
However! The last 2 breakpoints never get triggered. Any ideas?
I am trying to get actionable notifications working and I have gotten the actions to display when the notification is expanded, but I cannot get the delegate function to be called when I select an action. I am declaring self.notificationCenter.delegate = self in application(_:didFinishLaunchingWithOptions:), and, if I'm understanding correctly, when an action is selected it should call userNotificationCenter(_:didReceive:withCompletionHandler:), passing in the UNNotificationResponse object. But that method never gets triggered in my code. Any ideas why that may be happening?
The method you have mentioned above gets called as soon as you receive notification.
The method which is executed after clicking on action on notification is,
application:handleActionWithIdentifier:forRemoteNotification:completionHandler:
I figured out the issue. To handle notifications with content you have to add a service extension as a new target in the project. The last thing I ran was the service extension so the debugger wasn't stopping at breakpoints in the main app. I didn't know service extensions are essentially treated like completely separate apps. Since I was still in the process of working on the content of that method, what was in there was not working and it was hitting the breakpoints, so I thought it was not calling that function like it should.
I followed the hello world example on this page to set up lua-lgi and libnotify, successfully getting a notification that looks and acts the samea s if using os.execute("notify-send..."). Notify-send does not allow user actions, from what I've gathered, so I am attempting to directly use the libnotify library to display a notification with a button. When clicked in the notification, it should open a file. I am able to call the function described here with lua, using (building from the hello world example):
Hello:add_action("button", "Open", function(notification, action, user_data) os.open("gedit tmp") end)
which successfully displays a button with the label "Open" in the notification. However, the callback function is not called, so the file does not open. I also noticed when running the script, it actually finishes executing before the notification has fully appeared, so if the program is not running anymore when the button in the notification is clicked, then that's one reason why the callback isn't being called, if it's working correctly up until that point. This is my first experience with lua-lgi, so I'm not sure how these types of callback functions translate into lua, or if they're even supported, which is probably what I'm really trying to understand here. Any help is appreciated regarding this issue, or insight into an alternative to displaying a notification with a button and callback via other means.
I am using Display.screenshot() to get a screen shot for the current displayed screen.
My application has all available persmissions set to allow,
it works well in all device application, but it doesn't work on Facebook and Twitter app -
on those apps i got an exception:
Error: net.rim.device.api.system.ControlledAccessException: Unauthorized attempt to attach to this application
what should I do to overcome this?
You seem to be calling Application.getApplication() somewhere in the code.
Your ApplicationMenuItem code generally runs within the UI application whose menu it is launched from. So when you click your ApplicationMenuItem within facebook app, it executes within the event dispatcher thread of facebook app.
However, since your code is not a part of the facebook app, it can't access its Application Object using the Application.getApplication() method.
If you are not calling this method yourself, maybe Display.screenshot() calls it internally. To solve this, you need to run the code in your app's event dispatcher thread. This can be done by using the special method addMenuItem(long, ApplicationMenuItem, ApplicationDescriptor) while registering the menu item and passing it your app descriptor.