In a PWA i require the users camera access for scanning QR codes. i use getUserMedia() to get the users permission, however, when you leave the device for a while and want to scan more QR codes, the devices prompts for permission again.
I can accept these permissions globally for the safari app so it doesn't show up when using the app in PWA mode.
However, using it as native PWA installed from the app-store, i get the prompt many times.
the app has a global setting for camera access, and it's set to true. html object <input type="file" accept="image/*" capture="environment"> then will NOT prompt the message again. however getUserMedia() WILL always keep prompting.
i find tons of peoples posts on the internet going back a couple of years.
I want the prompt to only show once.
solved:
#available(iOS 15.0, *)
func webView(_ webView: WKWebView,
requestMediaCapturePermissionFor
origin: WKSecurityOrigin,initiatedByFrame
frame: WKFrameInfo,type: WKMediaCaptureType,
decisionHandler: #escaping (WKPermissionDecision) -> Void){
decisionHandler(.grant)
}
Related
My tutorial is a WhatsApp/SnapChat app. Naturally the avatar image, country flag, user name, gender symbol and conversation data all come from the server and host app.
These kinds of apps do not use Parse like APIs or other 3rd party dependencies because they use REST/JSON with their own servers.
How do I get this same data and UI elements onto the watch table row? Do we have to re-write the same HTTP GET methods in our watch extension as well as re-copy UI elements into watchOS cassettes folder? Can we not just call the same methods that already exist in the iOS host app? I'm not sure how the Connectivity Framework would be used.
Could you please give an example of GET and POST methods to assign an avatar or username to the watch table row view object? For example for a Node.js server.
Since your iOS host app has already downloaded and deserialized the data, it doesn't make any sense for the watch to duplicate that code or effort and GET the same data.
As for providing an example, you should show what you tried in code, and explain the specific problem you're having.
Documentation
You should use the Watch Connectivity framework to share data between your iOS and watchOS apps.
You'll find a good introduction in the watchOS 2 Transition Guide. See Communicating with Your Companion iOS App for details.
Apple also provides Lister sample code which demonstrates how to use WCSession to transfer both application context and files between iOS and watchOS.
Since the host app is written in Obj-C should WatchConnectivity / WCSessionDelegate be imported into every file header file that contains data that needs to be sent to the watch extension?
WCSession is a singleton that you configure at launch time, early in the life of both your iOS app and watch extension. See the transition guide's Activating the Session Object for more information.
If you don't understand how or where your apps should handle watch connectivity, there are plenty of tutorials and sample projects which you can easily find via Google.
So based on what you said I just need to use the Connectivity Framework. sendMessageToWatch and didReceiveMessage methods.
The exact methods you use depend on what you want to transfer -- application context, user info, files, or messages -- and whether it takes place in the foreground or background. See the transition guide's Choosing the Right Communication Option for more information.
If you check some chat app projects that are already on GitHub you will see how to use Connectivity Framework precisely. Obj-C and Swift.
Here's one that specifically shows you how to pass messages back and forth.
https://github.com/carbamide/MessagingTest
This is not my code. As you can see code is almost the same.
ViewController.swift
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
if (WCSession.isSupported()) {
let session = WCSession.defaultSession()
session.delegate = self
session.activateSession()
}
}
func session(session: WCSession, didReceiveApplicationContext applicationContext: [String : AnyObject]) {
print(applicationContext)
let okButton = UIAlertAction(title: "OK", style: .Default, handler: nil)
let alert = UIAlertController(title: "Application Context Received", message: applicationContext.description, preferredStyle: .Alert)
alert.addAction(okButton)
self.presentViewController(alert, animated: true, completion: nil)
}
watchOS InterfaceController.swift
func session(session: WCSession, didReceiveApplicationContext applicationContext: [String : AnyObject]) {
print(applicationContext)
let okButton = WKAlertAction(title: "OK", style: WKAlertActionStyle.Default, handler: { () -> Void in })
self.presentAlertControllerWithTitle("Application Context Received", message: applicationContext.description, preferredStyle: .Alert, actions: [okButton])
}
I have a ViewController that will request access to location services on init via
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined)
{
[_locationManager requestWhenInUseAuthorization];
}
This triggers the "Allow app to access your location while you use the app?"-alert.
I use [self addUIInterruptionMonitorWithDescription:handler:] to react to this. I am encountering the following problem: after dismissing the request-dialog, the ui-test does not continue. The alert is dismissed, but Xcode waits for the app to become idle, but it looks like the app is idle:
t = 67.35s Wait for app to idle
The test fails, because the app is stuck here. If i tap into the simulator, Xcode logs.
t = 72.27s Synthesize event
and continues the test.
Is there a reason, why Xcode tries to wait for the app? A workaround seems to be to tell Xcode that the UI changed or an event happened. Is there a way to trigger this?
After presenting the alert you must interact with the interface. This is a known bug with Xcode 7.2. Simply tapping the app works just fine, but is required.
addUIInterruptionMonitorWithDescription("Location Dialog") { (alert) -> Bool in
alert.buttons["Allow"].tap()
return true
}
app.buttons["Find Games Nearby?"].tap()
app.tap() // need to interact with the app for the handler to fire
XCTAssert(app.staticTexts["Authorized"].exists)
See my blog post for more information.
I want to integrate some voice commands in my windows phone 8.1 app.
The first thing I want to do is to open my app by a voice command and navigate to a certain page.
According to MSDN article Quickstart: Voice commands (XAML) I can use the override of protected virtual void OnActivated(IActivatedEventArgs args) method in App.xaml.cs to meet my requirements. But it does'nt work the way I though it would!
I have the method with the following structure:
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.VoiceCommand)
{
var commandArgs = args as VoiceCommandActivatedEventArgs;
if (commandArgs != null)
{
// ... some logic here
}
}
}
The problem is when I'm activating my app by saying "Open 'name of my app' [optional words]" the app opens but the Activated event never fires! The app opens and OnLaunched event fires. So I can't even enter the OnActivated method.
Does anyone know the problem? Why can't I enter OnActivated method using voice commands?
P.S. I tried it with a simulator as well as with a real device.
you can see this article,
http://t.co/Q5hRxRPvwR
is in spanish, but you will understand.
After you install the app and run it, the xml should be installed, like said in documentation.
After ask to cortana "What can I say?" it will show all you can said, and the apps that supports cortana. Choose you app and you will see what you can say for your app, like
If you say what your app can listen, your app will be activated.
One Quick Question:
I want to navigate to settings(cellular..) from an secondary livetitle.
The Problem is the targetUrl for the Shelltitle(selectedShortcutsMenuControl.TargetUrl) in my app looks like this: "cellular",
and thats not an valid Uri format.
Exception : "An exception of type 'System.UriFormatException' occurred
in System.ni.dll but was not handled in user code"
StandardTileData data = new StandardTileData();
data.Title = selectedShortcutsMenuControl.Title;
data.BackgroundImage = myUri;
ShellTile.Create(new Uri(selectedShortcutsMenuControl.TargetUrl,UriKind.RelativeOrAbsolute), data);
Is there a way to fix this or is there a way, to directly navigate to cellular Settings form the livetitle?
<ctl:MenuData x:Key="ShortcutsMenuControlData">
<ctl:MenuItemData Title="Cellular" TargetUrl="wifi" Image="/Images/Item-fc0d2405-5b0f-4f3d-ba3e-5b93fbfe2c44.png"/>
<ctl:MenuItemData Title="WiFi" TargetUrl="cellular" Image="/Images/Item-c9f6c2c7-44e1-4079-ad90-e31b8a59333e.png"/>
<ctl:MenuItemData Title="Airplain Mode" TargetUrl="plaine" Image="/Images/Item-10845593-26f7-485a-bef7-cf9b9b0cf9fe.png"/>
<ctl:MenuItemData Title="Bluetooth" TargetUrl="bluetooth" Image="/Images/Item-294e2b67-5534-43b3-ae4e-aecf180c9274.png"/>
</ctl:MenuData>
So inorder to navigate to the native phone settings you need to use the built in URI schemes.
They can be found on MSDN here
Specifically for the ones you are asking for the codes are
ms-settings-airplanemode: Launches the Airplane Mode Settings app.
ms-settings-cellular: Launches the Cellular Settings app.
ms-settings-bluetooth: Launches the Bluetooth Settings app.
ms-settings-wifi: Launches the Wi-Fi Settings app.
replace your target url's with these and it should work
I am experimenting with azure mobile services and have implemented the authentication example here. This works on most devices ( iOs, IE9 and chrome on desktop, IE10 Surface RT, android ) but on a WP8 device ( a Nokia 920, to be precise ) it returns
"Cannot reach window opener. It may be on a different Internet Explorer zone"
after attempting to return from the authenication providers pop-up. This is mentioned briefly in the link above, but only wrt to connecting to the service from localhost. This is not the case here and other devices work fine. It does not seem to be a problem with any particular authentication provider - all ( facebook, google, twitter, windows connect ) return the same message. And as these other devices work, it seems unlikely that the service is mis-configured, but there could very well be something subtle that I'm missing.
The way I got the authentication to work is not to use Facebook JavaScript SDK, but another flow, described here https://developers.facebook.com/docs/facebook-login/login-flow-for-web-no-jssdk/#step2
For handling the response when I get the redirect back from Facebook, I used the following code:
function handleLoginResponse() {
var frag = $.deparam.fragment();
if (frag.hasOwnProperty("access_token")) {
client.login("facebook", { access_token: frag.access_token }).then(
function () {
// do your thing when logged in
}, function (error) {
alert(error);
});
}
}
This code makes use of jQuery BBQ plugin, found here http://benalman.com/projects/jquery-bbq-plugin/.
This way I can get Facebook auth to work on WP8 and I'm able to pass the access token to Mobile Services login.
A slight problem is that now the access token sticks in my site URL, which I think is a problem if the user decides to share the URL, for example. I think I can get around this by e.g. putting the info in a cookie (or local storage) and then redirecting to the plain URL of my site.