Posting this question with an answer so other's can find it.
We have an app on the store which records an activity's path. When we updated the WatchOS to version 4, our background gps updates stopped when the app transitioned into the background.
Some research found this link on Apple's Developer site that shows we need to set a new property in the location manager.
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
if (#available(watchOS 4.0, *)) {
self.locationManager.activityType = CLActivityTypeOther;
self.locationManager.allowsBackgroundLocationUpdates = YES; // NEW!!
}
[self.locationManager startUpdatingLocation];
See the line marked "NEW!!" That's what allowed the app to receive background location updates again. You also need to have the properties set as mentioned in the link.
Apps that want to receive location updates when suspended must include
the UIBackgroundModes key (with the location value) in their app’s
Info.plist file and set the value of this property to YES. The
presence of the UIBackgroundModes key with the location value is
required for background updates
Related
Using the HERE iOS Premium SDK 3.18 to create a routing App and I can't figure out what is needed in order to enable the Realistic View events in order to get signpost data for maneuvers in the route.
I have specified the NavigationManager Delegate and created functions for the event callbacks. When I create a route and run a simulation on the route, I never receive either of the realistic view events. I have scoured the User Guide and the API Reference but can't get the events.
func navigationManager(_ navigationManager: NMANavigationManager, didUpdateRealisticViewsForNextManeuver realisticViews: [NSNumber : [String : NMAImage]]) {
mapState.status = "Realistic View Updated for Next Maneuver!"
}
func navigationManager(_ navigationManager: NMANavigationManager, didUpdateRealisticViewsForCurrentManeuver realisticViews: [NSNumber : [String : NMAImage]]) {
print("RealisticViews: \(realisticViews.count)")
for key in realisticViews.keys {
print("key: \(key)")
}
mapState.status = "Realistic View Updated for Current Maneuver!"
}
======
Update: I located my problem, I was missing the step to register the realisticview aspect ratios after doing that I started receiving the events. From the User Guide:
"The Realistic View feature is disabled by default. To enable it, use NMANavigationManager.realisticViewMode property and set the view mode to NMARealisticViewDay or NMARealisticViewNight. Next, register the desired image aspect ratios by using NMANavigationManager.realisticViewAspectRatios property."
====== Update: I located my problem, I was missing the step to register the realisticview aspect ratios after doing that I started receiving the events. From the User Guide:
"The Realistic View feature is disabled by default. To enable it, use NMANavigationManager.realisticViewMode property and set the view mode to NMARealisticViewDay or NMARealisticViewNight. Next, register the desired image aspect ratios by using NMANavigationManager.realisticViewAspectRatios property."
We are using third party Audio/Video SDK in our Xamarin.Forms.Android project. Now problem is that by default audio comes in speaker mode, instead of ear-speaker. I was tried to search solution in internet and found below code to set audio in ear-speaker and speaker. After implement below code audio off in speaker but not able to listen via ear-speaker, if I set SpeakerphoneOn=true then I can listen via Speakerphone but if I set SpeakerphoneOn=false then I can't list via ear-speaker.
Additional point, Mode value is always comes "InCommunication" even after change to InCall or any other mode.
I have set below permission too in my Xamarin project.
Permission:
var audioManager = (Android.Media.AudioManager)Android.App.Application.Context.GetSystemService(Android.Content.Context.AudioService);
audioManager.SpeakerphoneOn = !audioManager.SpeakerphoneOn;
Check when mode is ear-speaker , the volume value whether is 0 .The volume of their two modes is controlled separately.
var audioManager = (Android.Media.AudioManager)Android.App.Application.Context.GetSystemService(Android.Content.Context.AudioService);
audioManager.Mode = Mode.InCommunication;
audioManager.SpeakerphoneOn = false;
audioManager.SetStreamVolume(Stream.Music, audioManager.GetStreamMaxVolume(Stream.Music), VolumeNotificationFlags.ShowUi);
My app uses Xamarin.Forms.Maps to display a map and also for geocoding. The map is displayed on a separate page when the user navigates to it from the main page. I use the geocoder to reverse geocode the current location so that I have the address. This is done from various places other than the map page.
When I run the app on a device (even in debug mode) the geocoder works right away in iOS and Android, but does not work in UWP. After I navigate to the map page and display the map, then go back to a different page to use the geocoder it starts working.
I saw a thread about the map not working with release build so I added the following code:
var laRendererAssemblies = new[] { typeof(Xamarin.Forms.Maps.UWP.MapRenderer).GetTypeInfo().Assembly };
Xamarin.Forms.Forms.Init(e, laRendererAssemblies);
//Xamarin.Forms.Forms.Init(e);
Xamarin.FormsMaps.Init("MyBingMapsKey");
This has not helped the issue with the Xamarin.Forms.Maps.Geocoder. I also tried creating an instance of Xamarin.Forms.Maps.Map in my main page, but that did not help either. Is there a way to prime the map component so that the Geocoder will work on a device? (My test device is ARM, but it happens when I run on Local
Machine (Win 10) too)
Following is a snippet of the call to the Geocoder (which works fine once the user has navigated to the Map page and back - and it works fine in iOS and Android - and as such I don't believe it is a problem with the code, but here it is):
public static async Task<Plugin.Geolocator.Abstractions.Position> Geocode(string address)
{
try
{
var loGeocoder = new Xamarin.Forms.Maps.Geocoder();
System.Diagnostics.Debug.WriteLine("Get Lat/Lon");
var lcolPositions = await loGeocoder.GetPositionsForAddressAsync(address);
if (lcolPositions != null)
After doing some research and ensuring that your geodecode class being static wouldn't mess with the async/await pattern in the UWP build. I've come across a few references to this particular problem with the built in Forms.Map geodecoder elsewhere, not just for UWP it has also been noted for android‡.
I took some time to have a look at one of our current cross-platform applications that we have in the app stores, and according to our internal documentation we switched out both the xamarin.forms map, and the geodecoder for custom ones.
The plugin that we use for our cross-platform application is the 'GelocatorPlugin' created by james montemagno, and can be found here.
It can be added to your project as a Nuget package if you prefer, and the implementation of it is very similar to the default one, so there's very little code to change. The primary benefit is that the UWP element of the geodecode plugin has been modified to take into account windows advanced tracking scenarios (details found here).
It should be a lot more stable than the one your using, once installed you simply use it like so:
Reverse Geocoding
Based on a location that is passed in, thi swill grab a list of
addresses.
UWP requires a Bing Map Key, which you can acquire by reading this
piece of documentation.
try
{
var addresses = await locator.GetAddressesForPositionAsync (position, string mapKey = null);
var address = addresses.FirstOrDefault();
if(address == null)
Console.WriteLine ("No address found for position.");
else
Console.WriteLine ("Addresss: {0} {1} {2}", address.Thoroughfare, address.Locality, address.Country);
}
catch(Exception ex)
{
Debug.WriteLine("Unable to get address: " + ex);
}
‡ Links to similar problems - Link 1, Link 2
resolved after added following lines in APP.xaml.cs (UWP project)
Xamarin.FormsMaps.Init("bingmapkey");
Windows.Services.Maps.MapService.ServiceToken = "bingmapkey";
I have just updated to the new Xcode beta 6.0 and when trying to compile for an ipad mini with iOS 8 I am getting a weird error in the console:
"Attempt to add read-only file at path file:///var/mobile/Media/PhotoData/Photos.sqlite?readonly_shm=1 read/write. Adding it read-only instead. This will be a hard error in the future; you must specify the NSReadOnlyPersistentStoreOption"
This happens when executing the following code:
if ([self.rootDelegate respondsToSelector:#selector(wImageRequiresAPhotoPicker:)]){
[self.rootDelegate wImageRequiresAPhotoPicker:(DWImage*)item];
}
And:
-(void)wImageRequiresAPhotoPicker:(DWImage *)img{
self.selectedWimg = img;
DWImagePickerController *imgPicker = [[DWImagePickerController alloc] init];
[imgPicker setDelegate:self];
[imgPicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[imgPicker setAllowsEditing:YES];
[imgPicker setModalPresentationStyle:UIModalPresentationCurrentContext];
UIPopoverController *popOver = [[UIPopoverController alloc] initWithContentViewController:imgPicker];
popOver.delegate = self;
self.popoverImageViewController = popOver;
[self.popoverImageViewController presentPopoverFromRect:img.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
Does anyone have a clue of why this is happening?
Most likely a newly introduced bug in iOS 8 beta 2. Let's see how it develops.
It seems that ALAssetsLibrary requests internally read & write access to Photos.sqlite database, and it can only gain read access. I'm receiving the same error with this call:
[self.assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
...
It is a core data error, and since my app does not use core data, and I receive the error when I access the photo library picker, I'm gonna say it is on Apple, and a bug. Apparently files are attempting to be added as read/write and they are read only. I'm pretty sure Apple should know this, since they set up the image picker. I'm just trying to access it.
self.pickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
I tried the method:
QWebSettings* settings = QWebSettings::globalSettings();
settings->setAttribute(QWebSettings::LocalStorageEnabled, true);
auto path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
settings->setOfflineStoragePath(path);
window.localStorage is true(not null or undefined), but when I insert a item into the localStorage:
localStorage.setItem("b","isaac");
alert(localStorage["b"]);
The error is happened, and the error messages in the webkit inspector console are:
QuotaExceededError: DOM Exception 22: An attempt was made to add something to storage that exceeded the quota.
I was raging all day, because it was not working after restart of the app.
So I think this will be helpfull for someone:
QWebSettings* settings = QWebSettings::globalSettings();
settings->setAttribute(QWebSettings::LocalStorageEnabled, true);
auto path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
settings->setOfflineStoragePath(path);
settings->enablePersistentStorage(path);
Notice the enablePersistentStorage
I forgot I've enable a very important swithcer:
settings->setAttribute(QWebSettings::PrivateBrowsingEnabled,true);
This will set the browser to private mode and prevent you to insert value to localStorage. But the official api doc doesn't mention it.
You just set disable the switcher can solve the problem:
settings->setAttribute(QWebSettings::PrivateBrowsingEnabled,false);