# Mobile improvements (with FPC): local notifications on Android, consent for AdMob, better iOS savegame location

**URL:** <https://forum.castle-engine.io/t/mobile-improvements-with-fpc-local-notifications-on-android-consent-for-admob-better-ios-savegame-location/2267>\
**Category:** News\
**Created:** [November 10, 2026, 11:13am UTC](https://forum.castle-engine.io/t/mobile-improvements-with-fpc-local-notifications-on-android-consent-for-admob-better-ios-savegame-location/2267 "2026-11-10T11:13:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)\
**Post date:** [November 10, 2026, 11:13am UTC](https://forum.castle-engine.io/t/mobile-improvements-with-fpc-local-notifications-on-android-consent-for-admob-better-ios-savegame-location/2267/1 "2026-11-10T11:13:03Z")

</div>

| [![Local notifications example](https://forum.castle-engine.io/uploads/default/original/2X/0/0212a79adf054ee5f5e5fbb70643e831397e6605.png)](https://castle-engine.io/wp/wp-content/uploads/2026/11/screenshot.png "Local notifications example") |
| [![Local notification on Android](https://forum.castle-engine.io/uploads/default/original/2X/b/bdef16c05b2faddefb48679a99c42913a7985bc1.png)](https://castle-engine.io/wp/wp-content/uploads/2026/11/screenshot_notification.png "Local notification on Android") |

Last news post was all about mobile development with Delphi. Let’s follow this with a list of improvements for mobile development with FPC!

1. We have a new Android service [local\_notifications](https://github.com/castle-engine/castle-engine/blob/master/tools/build-tool/data/android/services/local_notifications/README.adoc) to send notifications.
  - An example showing the capabilities of it is in [examples/mobile/local\_notifications](https://github.com/castle-engine/castle-engine/tree/master/examples/mobile/local_notifications).

  - The [API is nice and simple](https://castle-engine.io/apidoc/html/CastleLocalNotifications.TLocalNotifications.html).

  - Big thanks to [Hamid reza Kabiri](https://github.com/kabiri) for implementing this!

  - Note: These are _local_ notifications, which means you send them when your application is running (to display immediately or after a specified delay). Contrast this with _push_ notifications, which require a backend that determines the notification time — this would be a separate service.

  - Note: This service is for sending notifications using FPC. If you use Delphi, use [FireMonkey API for notifications](https://docwiki.embarcadero.com/RADStudio/Athens/en/Using_Notifications).

2. Our [AdMob service on Android](https://github.com/castle-engine/castle-engine/blob/master/tools/build-tool/data/android/services/admob/README.adoc) now supports asking the user for consent before showing ads.

3. All [Android services](https://castle-engine.io/android_services) can automatically bump Android’s “min SDK version”. This allows you to “just use” services like [admob](https://github.com/castle-engine/castle-engine/blob/master/tools/build-tool/data/android/services/admob/README.adoc) or [game\_analytics](https://github.com/castle-engine/castle-engine/blob/master/tools/build-tool/data/android/services/game_analytics/README.adoc), without additional tweaking of the manifest file.

4. We have [updated _Gradle_ version used by our Android build files](https://github.com/castle-engine/castle-engine/commit/5b57ed12b890a858c7a86b798026b1f6b4aa5fea), to support _Java \>= 25_ for Android building.

5. On iOS, we change the `castle-config:/` location to one recommended by Apple. Read on for details.

## Change of iOS savegame location

Only for iOS applications built with FPC: We change where we store configuration files.

This applies to user preferences, savegames, etc. — everything you access using configuration files [castle-config:/xxx URLs](https://castle-engine.io/url#castle-config).

- Previously, we stored config files (`castle-config:/` URLs) in `NSLibraryDirectory`.
- Now, we store them in `NSApplicationSupportDirectory`.

The reason for the change: the new location follows Apple recommendations. See Apple [“File System Basics” -\> “Where You Should Put Your App’s Files”](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html):

_“Put app-created support files in the Library/Application support/ directory. In general, this directory includes files that the app uses to run but that should remain hidden from the user. This directory can also include data files, configuration files, templates (…)”._

The change is aligned with [what happens with Delphi](https://castle-engine.io/delphi_mobile). We determine [iOS preferences location for Delphi using different code](https://github.com/castle-engine/castle-engine/blob/b4cb2d57ca20fd1a76079d8bd0450ae7f683fa20/src/base/castleutils_delphi_compatibility.inc#L220) but we made sure it is effectively calculating the same. See [Objective-C code doing the equivalent for FPC](https://github.com/castle-engine/castle-engine/blob/b4cb2d57ca20fd1a76079d8bd0450ae7f683fa20/tools/build-tool/data/ios/xcode_project/cge_project_name/OpenGLController.m#L249). So your iOS applications will read/write the same configuration, no matter which compiler you use.

The new directory is in practice a subdirectory of the old one: it is `<sandbox>/Library/Application Support/`, while previously it was `<sandbox>/Library/`.

_Backward compatibility:_

The change itself could be a trivial 1-line change, but we need to do more work to be backward compatible. If you have an existing application, using CGE and FPC, on iOS, and you have saved some configuration -\> if you rebuild your application with the new engine, it will still open the old configuration.

The backward compatibility mechanism should “just work” if all you do is read / write config files using `castle-config:/...` URLs. Opening `castle-config:/...` URLs with engine API, testing with `UriExists` -\> will just work.

To account for edge-cases, and people who write their own Objective-C code, let us describe the details of how the compatibility was done:

- The library now exposes an additional routine, `CGEApp_SetFallbackConfigDirectory`.

- Our Objective-C code [passes there the old config location](https://github.com/castle-engine/castle-engine/blob/2d57b337357c50f996a54941e274d4783cc8c2a4/tools/build-tool/data/ios/xcode_project/cge_project_name/OpenGLController.m#L216).

- From your application, if you try to open the URL at `castle-config:/`, or check for existence using `UriExists`, we will first check the new config location, and then (if set) we will use the old location provided to `CGEApp_SetFallbackConfigDirectory`. This happens when `ResolveCastleConfigUrl` is called with 2nd parameter `UseFallbackIfNotExists` set to `true`.

- _Nothing else is using the fallback config directory. Writes will always go to the new, proper config directory._ So if you open and save a savegame on iOS, created with the old application version, the new application version will put it in the new location. Further reads will ignore the old file in the old location, since the file will exist in the new location. This should be invisible to the user on iOS (`<sandbox>/Library/` is not visible in any application), so it should not cause problems.

_Possible known gaps_:

1. Using `FindFiles` with `castle-config` protocol, like `FindFiles('castle-config:/savegames/*.sav', ...)` will not see the old savegames on iOS (in a fallback directory). If you need this to work:
  1. Avoid `FindFiles` with `castle-config` protocol on iOS with FPC. Use `UriFileExists` instead, e.g. check a list of possible savegame filenames. To be clear: You only need to be careful about this if you have users that have savegames in the old location (made with an old engine version). This concern doesn’t apply to new applications made with CGE for iOS.

  2. If the above advice is difficult, a fallback is to hack engine `tools/build-tool/data/ios/xcode_project/cge_project_name/OpenGLController.m` to use `NSLibraryDirectory` again (instead of `NSApplicationSupportDirectory`) for the config location. This is brutal but simple and effective: it gets you back to the old state, and it’s just a 1-line change. And let us know — so we can design a proper upgrade plan!

2. If you relied on `UriToFilenameSafe` to convert `castle-config` protocol on iOS with FPC, it will not see the fallback file. We don’t know in which context you use `UriToFilenameSafe`, so it only resolves to the new config location. If this is a problem, our advice:

Please contact us if this is causing any problems for you — we will propose solutions 🙂

As always, we hope you have fun developing games using _Castle Game Engine_ and we [appreciate your donations](https://www.patreon.com/c/castleengine).
