For iOS 8 I have added the following key to my plist:
NSLocationAlwaysUsageDescription
I also added:
// Check for iOS 8
if ([_locationManager respondsToSelector:#selector(requestAlwaysAuthorization)]) {
[_locationManager requestAlwaysAuthorization];
}
I deleted the app from my phone. Upon launch I get prompted if its ok to run location services in background as expected. I click yes. While the app is running I get locations and the location active icon is in the status bar.
However if I leave the app the location active icon soon disappears from the status bar and I no longer get locations.
Do I need to re setup the location manager when the app enters the background? Does the location manager property/variable need to be defined in the AppDelegate such that it never goes away?
You also have to set location updates in the background modes of your capabilities.
Related
I have developed an Xamarin forms application. In Android devices, Lenovo K6(v7.0) and Nexus 6 (v7.1.1), when the app is minimized and opened by clicking the app icon the opening page of the application is reset to default instead of showing the part in the page where the user has minimized the application. But, when the app is minimized and re-opened using the recently opened tabs it is resumed correctly.
This problem arises only in the mentioned two devices in all other devices the page is resumed from where it is minimized when the user re-opens the application on using both recent tabs or App icon click. If the close application then reopens it and application starts from Splash screen. In above scenario, the app starts with the home page and reset as default launch. I have started the download of my app and progressing the download. I have minimized the app and click app icon from the installed app on the device. Now, progress is reset and file stays as download file.
Please suggest on this to resolve it.
Regards,
Cheran
Original situation:
I'm developing a sandboxed app on macOS 10.13. It's a shoebox-like app consisting of a main window with toolbar. Autosaving for the window frame and toolbar configuration are set up in Interface Builder.
If I run and quit the app, I can see a preferences file (named <app-identifier>.plist) containing the expected data in the app's sandbox container. Everything works fine.
Extending the app with App Groups:
To allow data exchange with other sandboxed apps, I created an app group in my target's Capabilities tab of Xcode.
So far this works, i.e. an additional group container is created when launching the app. It is also possible to store shared preferences into the group container by creating a UserDefaults object via UserDefaults.init(suiteName:"<group-name>").
The problem:
After adding the App Group, the autosaving mechanism for e.g. the toolbar configuration no longer works. Starting and quitting the app on a clean Mac no longer creates a .plist file in the Preferences directory of the app container. Instead the console shows messages like this:
[User Defaults] attempt to set <value> for key in <key> in
non-persistent preferences domain CFPrefsPlistSource<address>
(Domain: <app-identifier>, User: kCFPreferencesCurrentUser,
ByHost: No, Container: (null), Contents Need Refresh: Yes)
It looks for me, that the autosaving mechanism is no longer able to write its data into the preferences file.
Is it possible to concurrently use standard UserDefaults and shared ones in the app groups?
Problem solved: after a rebooting the Mac, everything works as expected. This is really weird.
I have some odd behaviour in my app.
In my app delegate file I ask the user for permission to use their location while they use the app. This works fine and I can get their current location. After I get their initial location I stop updating location. Great. There is a button users can tap to start updating locations.
If the app is in the foreground I can see that locations are being added to my dictionary every second (I will change this to distanceFilter 10 later). If the user puts the app in to the background location services stop and I don't see the blue bar at the top of the screen.
I have:
Background modes for location updates enabled
NSLocationWhenInUseUsageDescription set (I am able to successfully ask the user for permission)
Started the location updates with startUpdatingLocation()
Tried setting the app to track location always (same result)
Deleted the app from my phone and reinstalled
In the previous version of my app (before Swift 2) this was working perfectly. I could see location being tracked even when the app was in the background.
I am testing on my iPhone not the simulator.
If anyone else has the same issue, I had updated my iPhone to iOS9 so it was required for me to add
locationManager.allowsBackgroundLocationUpdate = true
to my location manager.
The following worked for me, please note allowsBackgroundLocationUpdates is plural.
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.allowsBackgroundLocationUpdates = true
I'm using OSX's Notification Center APIs for the first time and can't seem to figure out how to make my app's icon to show up in the Notification badge.
The default "your app doesn't have an icon" icon keeps showing up:
Here's what I've done so far
I have created an icns file that includes 512, 256, 128, 32 & 16px versions
dragged the icon into the "App Icon" section of the target's summary
I made to sure to check the box to copy the icon into the project
the plist's "Icon file" section references the correct icon name (minus the .icns) part
Any ideas? The icon doesn't show up when I run the app thru Xcode or when I export an archive either.
I also have extracted the Sparrow.icns file from Sparrow.app and tried using that one instead of the one I made. That didn't work either.
I was able to fix this issue by incrementing the Build number in the General section for the build Target.
You can force the Notification Center to refresh all of the icons by deleting the Notification Center database file (~/Library/Application Support/NotificationCenter/SOME_UUID.db) and then killing the Notification Center process (e.g., from Activity Monitor).
Unfortunately this has the side effect of deleting your notification history, but this wasn't too much of an issue for me.
There's actually an ongoing debate on Apple's developer forums (link, link for people with access) about this. As far as I know, there's currently no real solution, but you can try the following:
Change your app's bundle ID and try it again. If you change it, clean your app, and change back, some people have reported success with seeing their icon show up.
Log in as another user. The caching Notification Center uses may be per-user, so you might be able to get the properly-iconned notifications as a different person.
The folder location has been moved for OSX 10.10+.
Following command takes to you to its new location:
$ cd `getconf DARWIN_USER_DIR`/com.apple.notificationcenter/db
and then
$ open .
Easiest way that I managed to get the icon to show up is change the Bundle Identifier in your project. This works on OSX 10.10.5 and XCode 7.2
(Once notification center picks up the change, you can change it back to your original bundle identifier if you already have a provisioning profile associated with it)
I have solved the issue by archiving my app and adding a copy to my applications folder. When the app is in Application folder, the icon is always visible even you run the app from XCode...
I tried all of the above suggestions but the only thing that worked for me on 10.14 was to delete DerivedData:
rm -rf ~/Library/Developer/Xcode/DerivedData
If anyone still having this issue, and none of the methods above worked, here is how I solved it:
open Notifications from the System Preference (easiest is to open Alfred or spotlight and type Notifications)
find your application and remove it (press backspace/delete button)
NOTE: this may remove all notifications
I am using Xcode 11.5 and I had the same problem. In my case tough, it was sufficient to clean build output, close and reopen the project. Then do a fresh build and let it run again. The icon was there afterwards.
Side note: I've placed the app icon for every size in the assets.xcassets file, except 1024 x 1024 pixels. Don't know if this is relevant or not. Hope that helps.
Does any one know why the location indicator stay on for certain bundle identifer vs. the others?
I am using an Apple sample LocateMe app, installed on my iOS device running version 5.0.1. When I'm using an old bundle identifier, the location indicator stays on the status bar, after the CLLocationManager stopUpdatingLocation is being call.
But, when I'm using the same exact app, with the only difference being a new bundle id, the app works as expected and the location indicator disappear once the stopUpdatingLocation is being called.
Did anyone experience this problem or can explain it?
I finally figured that if I reset the Location Warnings from the Settings, the bug disappear.
From your iOS Settings select General | Reset | Reset Location Warnings. This will reset the warning to all the apps. This mean that the next time you start an app that requires location, the iOS will prompt you with the location permission dialog.
Select 'Reset Warnings' from the action sheet.
When running the app again, the iOS will prompts you with the location permission dialog (if it doesn't - repeat the process above to reset the location warnings). After selecting yes, the app behaves as expected, and the location indicator disappears after few seconds.
Did you try to also stopMonitoringSignificantLocationChanges ? It worked for me.