So I am using flutter-permission-handler to handle all the permission functionality,
for E.G
// Location Permission
askForLocation() async {
// Permission type
var status = await Permission.location.request();
if (status.isGranted) {
_location.value = status.isGranted;
update();
} else {
print('open setting');
openAppSettings();
}
}
work as expected on android but when it comes to ios it always returns permanently denied
however, with that kind of return it should open the app setting page, it opens only the home setting page on the simulator and a physical device.
my first response was to try to get the app from the setting page I couldn't find the app itself.
you can see the behaviour in this video
https://youtu.be/ugpFMFyKhLY
anyone facing the same issue?
Related
I had used the health package in flutter for steps and running data in android the google fit and physical activity permission are set perfectly but in iOS, it is not asking for health kit permission all other permissions are working perfectly fine here is the code which I had written for permission request
Future<void> requestActivityPermission() async {
if (Platform.isAndroid) {
final permissionStatus = await Permission.activityRecognition.request();
if (permissionStatus.isDenied || permissionStatus.isPermanentlyDenied) {
_activityPermanenetlyDeniedCase();
return;
} else {
permissionStatus.isGranted;
fetchTotalStepData();
}
} else {
final permissionStatus = await Permission.activityRecognition.request();
if (permissionStatus.isDenied || permissionStatus.isPermanentlyDenied) {
_activityPermanenetlyDeniedCase();
return;
} else {
permissionStatus.isGranted;
fetchTotalStepData();
}
}
}
The requestActivityPermission function is called in the initState Method.
The _activityPermanenetlyDeniedCase function directly opens up, in that function i had a dialog box showing open setting, but in the setting there is no healthkit permission.
I am expecting a popup permission for healthKit
You need to specify which permission you are using in Info.plist file under ios/ directory.
<key>NSHealthShareUsageDescription</key>
<string>We will sync your data with the Apple Health app to give you better insights</string>
<key>NSHealthUpdateUsageDescription</key>
<string>We will sync your data with the Apple Health app to give you better insights</string>
Refer here
Check that the healthkit is activated in both the debug and release tabs
I am developing a PWA that requires Push-Notifications. Sadly IOS/Safari does not support https://w3c.github.io/push-api/#pushmanager-interface for now, so I think i might have to wrap a native APP around in some way.
In Android (before their "Trusted Web Activities" was a thing) you could use a WebView to basically display a headless Chrome-View in your App. Whats the equivalent in IOS and how does the interaction between push-notifications and the Webapp (the browser need to jump to a specific page) work?
One more thing I need is integration with our companys Mobile Device Management, which is Microsoft Intune. Having integrated MDMs in Android in the past i Know that this might be a major pain in the a**, so i'm considering to build the wrapper myself, for maximum flexibility. Another option would be something like Ionic, not sure now.
This may not necessarily work in your situation, but I had the exact same issue with a PWA for Safari and I solved it by just using long polling. It will allow you to get around all of the limitations with Safari and I was able to redirect and load sections within our SPA.
async function subscribe() {
let response = await fetch("/subscribe");
if (response.status == 502) {
// Status 502 is a connection timeout error,
// may happen when the connection was pending for too long,
// and the remote server or a proxy closed it
// let's reconnect
await subscribe();
} else if (response.status != 200) {
// An error - let's show it
showMessage(response.statusText);
// Reconnect in one second
await new Promise(resolve => setTimeout(resolve, 1000));
await subscribe();
} else {
// Get and show the message
let message = await response.text();
showMessage(message);
// Call subscribe() again to get the next message
await subscribe();
}
}
subscribe();
https://javascript.info/long-polling
I am working on a Xamarin iOS project. During my testing, I have found that if I perform a delete action, and lock the device while the task is executing, the app crashes. What is the proper way to prevent this from occurring?
// DeleteItem calls the api
bool success = await ViewModel.DeleteItem(itemToDelete);
if (success)
{
ViewController.NavigationController.PopToRootViewController(true);
}
else
{
DisplayErrorMessage("An error encountered.");
}
Edit:
Upon looking at the device log, this is the error that occurred:
I'm using the Uber Rides iOS SDK and currently only interested only in how long an uber will take to arrive, we just launch the uber app to the app if the user wants to proceed.
Strangely on some iPhones and the simulator it returns a result pretty much always (unless no cars available), but on others it says not authorised as a response.
Here is the code for the call:
func fetchTimeEstimates(from location: CLLocation, completion: #escaping (_ estimate: TimeEstimate?) -> Void) {
ridesClient.fetchTimeEstimates(pickupLocation: location) { (estimates, response) in
if response.statusCode != 200 || estimates.isEmpty {
print("UBER fetchTimeEstimates returned \(response.statusCode)")
completion(nil)
return
}
// Set default to uberX
for i in 0...estimates.count - 1 {
if let id = estimates[i].productID, id == UberRides.uberXProductId {
completion(estimates[i])
return
}
}
completion(estimates[0])
}
}
Im using server token setup in my plist
Although it either consistently works or does not on peoples phones, It does not seem a consistent pattern, i.e. its not that the first 5 devices worked and then it stopped working after that, or type of phone or OS version.
Heres what I tried:
Adding a failing devices user to list of developers in the dashboard authorisation screen, no difference.
Requesting full api access for a 'request', nope
checking if a brand new phone 8 with brand new user credentials both for the phone and uber login, works fine so don't explain why we go two people in the office where its consistently refused.
adding the app ID in the developer console.
Any ideas why I'm getting inconsistent results, its a challenge to debug as it always works on my test phones, but annoyingly it fails consistently on the CEO's phone.
I'm working on a Safari Content Blocking extension. I intend to show setup instructions if the extension is disabled and to show settings if it is conversely enabled. How can I determine if the extension is enabled by the user?
I've seen this method to detect if a custom keyboard is activated but there's no key on NSUserDefaults that relates to Safari Content Blockers.
As of iOS 10, there is a new method in SFContentBlockerManager to support this:
getStateOfContentBlocker(withIdentifier:completionHandler:)
And you call it like this (Swift 3):
SFContentBlockerManager.getStateOfContentBlocker(withIdentifier: "your.identifier.here", completionHandler: { (state, error) in
if let error = error {
// TODO: handle the error
}
if let state = state {
let contentBlockerIsEnabled = state.isEnabled
// TODO: do something with this value
}
})
You could utilize a SFSafariViewController to load a custom website. This website checks whether it is able to show something that your content blocker should block. Then redirect to the respective custom url (success/failure) that your app previously registered for. You could even use a hidden Safari View Controller without animation to avoid any distraction from the user's perspective (as shown here). (I guess this technique is used by former content blocker Peace)
Steps
App
Register custom URLs for success/failure
Register for notification callback using the NotificationCenter (e.g.
contentBlockerEnabled)
Use SFSafariViewController to show a custom website and include the following rule in blockerList.json:
{
"action": {
"type": "css-display-none",
"selector": ".blocked_selector"
},
"trigger": {
"url-filter": ".*"
}
}
Website
Check for blocked content:
if($('.blocked_selector').css('display') == "none") {
// Content blocker enabled
}
Redirect to custom URL (success/failure)
App
Post notification from
application:openURL:options: (success/failure based on called url)
Update 18/01
Following on from Tilo's hypothesis, I built the proposed solution. I wrote about what I learnt on Medium and you can grab the source files from GitHub.
TL;DR It works but only temperamentally due to the latency incurred of the content blocking rules database to update. A potential workaround is redirecting the test page to create an artificial delay.