Skip to content

Commit 223c913

Browse files
deadlyjackAjit Kumar
andauthored
fix(ads): harden startup and retire ad-free passes (#34)
Bound iOS ATT and StoreKit startup waits, reject stale callbacks, and cache verified ad environments with a monotonic retry cooldown. Guard rewarded presentation recovery on both platforms and keep retries bounded. Remove new ad-free pass offers, redemption APIs, unused academy ad units, and related UI/translations while honoring previously earned time. Reuse one share service across bridge calls and fix native callback lifetime warnings and Alpine SDK cache invalidation. Prepare build 1023 and keep local review notes ignored. Validation before commit: 34 selected iOS native/bridge tests passed, including a final 14-test ATT/StoreKit rerun; unsigned device Release build succeeded. Earlier unchanged JS and Android suites passed. Formatting and staged whitespace checks pass. Physical TestFlight verification remains. BREAKING CHANGE: system.redeemReward and the retired ad-free-pass offer APIs/exports are removed; existing earned ad-free time remains valid. Co-authored-by: Ajit Kumar <dellevenjack@gmail>
1 parent 1ff48d3 commit 223c913

107 files changed

Lines changed: 1812 additions & 1343 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ platforms/**/bundle/
2727
**/Config.xcconfig
2828
platforms/ios/**/*.xcuserstate
2929
platforms/ios/**/xcuserdata/
30+
/docs/reviews/

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## Unreleased
4+
5+
* Ad-free pass redemption is discontinued; previously earned time remains valid until expiry. The `system.redeemReward` wrapper and native action have been removed. Plugins using that action must stop offering redemption. Internal pass-offer helpers and the `isWatchingRewardedAd` export were also removed.
6+
37
## v1.13.5
48

59
* fix(terminal): stop proot "can't sanitize binding" fd warnings by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2878

‎CONTRIBUTING.md‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,24 @@ implementation. Version, build number and display name are synced from
247247
services work without a distribution certificate.
248248

249249
The target includes `platforms/ios/ads`, Google Mobile Ads/UMP and advertising
250-
metadata. Debug builds use Google's iOS test units. Release builds require
251-
`ACODE_IOS_ADMOB_APP_ID`, `ACODE_IOS_ADMOB_BANNER_ID`,
252-
`ACODE_IOS_ADMOB_INTERSTITIAL_ID` and `ACODE_IOS_ADMOB_REWARDED_ID`.
253-
See [iOS advertising](docs/ios-advertising.md) for consent testing, source provenance
254-
and validation limits. Run the normal script before building `runner` in Xcode;
255-
it prepares `.ios-build/App-Info.plist` and the matching web bundle.
250+
metadata. `ads.json` supplies ad-unit IDs through the web build configuration;
251+
`dev/scripts/iosAds.js` separately writes the app ID and advertising metadata into
252+
`.ios-build/App-Info.plist`. Run the normal script before building `runner` in Xcode
253+
to prepare both the plist and web bundle. The adapted AdMob Plus code retains its
254+
MIT notice in `platforms/ios/ads/AdMobPlus-LICENSE.txt`.
255+
256+
The app gathers UMP consent, then native startup waits for ATT to settle before
257+
starting Mobile Ads; consent is checked again before startup and ad requests.
258+
ATT waits are bounded to 30 seconds. A timeout fails startup without granting
259+
authorization; retry/foreground checks read the OS status, and cancellation never
260+
starts a second prompt while the original OS request is outstanding.
261+
On physical Release builds, a verified StoreKit sandbox/Xcode environment selects
262+
Google demo units. A failed, unverified or timed-out lookup keeps the configured
263+
units; the lookup deadline is three seconds. Verified environments are cached for
264+
the process; failed/unverified lookups retry after a 30-second cooldown, and
265+
concurrent lookups share one request. Debug/simulator selection comes from
266+
the build configuration and SDK test-device behavior. Simulator tests do not
267+
establish TestFlight/App Review environment selection or production ad fill.
256268

257269
The icon picker uses UIKit alternate icons and the existing reward/Pro gates.
258270
`runner.icon` and the fifteen alternate app-icon sets use Acode's existing
@@ -264,6 +276,10 @@ iPhone and iPad. It uses the local StoreKit Pro fixture to unlock the picker.
264276
Native tests cover packaged icons
265277
and the bridge; shared tests cover reward and purchase gates.
266278

279+
Calling `Bridge.setup()` again intentionally invalidates callbacks from the old
280+
navigation and resets its services before rebuilding them for the supplied WebView.
281+
Normal page navigation calls `reset()` and reuses the same WebView and services.
282+
267283
The `System` file utilities retain Android's result shapes, newline semantics and
268284
nonrecursive deletion while restricting paths to the sandbox or granted Files
269285
folders. Reward-pass state uses Keychain. Android file-edit intents and launcher

‎ads.json‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@
55
"banner": "ca-app-pub-5911839694379275/9157899592",
66
"interstitial": "ca-app-pub-5911839694379275/9570937608",
77
"rewarded": "ca-app-pub-5911839694379275/1633667633",
8-
"academyRewarded": "ca-app-pub-5911839694379275/3893763807",
9-
"academyInterstitial": "ca-app-pub-5911839694379275/7819275372",
108
"appOpen": "ca-app-pub-5911839694379275/4600740197"
119
},
1210
"test": {
1311
"appId": "ca-app-pub-3940256099942544~3347511713",
1412
"banner": "ca-app-pub-3940256099942544/6300978111",
1513
"interstitial": "ca-app-pub-3940256099942544/1033173712",
1614
"rewarded": "ca-app-pub-3940256099942544/5224354917",
17-
"academyRewarded": "ca-app-pub-3940256099942544/5224354917",
18-
"academyInterstitial": "ca-app-pub-3940256099942544/1033173712",
1915
"appOpen": "ca-app-pub-3940256099942544/9257395921"
2016
}
2117
},
@@ -25,17 +21,13 @@
2521
"banner": "ca-app-pub-5911839694379275/7672969208",
2622
"interstitial": "ca-app-pub-5911839694379275/8054492011",
2723
"rewarded": "ca-app-pub-5911839694379275/4550361278",
28-
"academyRewarded": "ca-app-pub-5911839694379275/4716873072",
29-
"academyInterstitial": "ca-app-pub-5911839694379275/5428328674",
3024
"appOpen": "ca-app-pub-5911839694379275/4115247005"
3125
},
3226
"test": {
3327
"appId": "ca-app-pub-3940256099942544~1458002511",
3428
"banner": "ca-app-pub-3940256099942544/2435281174",
3529
"interstitial": "ca-app-pub-3940256099942544/4411468910",
3630
"rewarded": "ca-app-pub-3940256099942544/1712485313",
37-
"academyRewarded": "ca-app-pub-3940256099942544/1712485313",
38-
"academyInterstitial": "ca-app-pub-3940256099942544/4411468910",
3931
"appOpen": "ca-app-pub-3940256099942544/5575463023"
4032
}
4133
}

‎dev/config.js‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ function getAdConfig(platform, mode) {
1515
"banner",
1616
"interstitial",
1717
"rewarded",
18-
"academyRewarded",
19-
"academyInterstitial",
2018
"appOpen",
2119
]) {
2220
const id = config[name];

‎docs/ios-advertising.md‎

Lines changed: 0 additions & 128 deletions
This file was deleted.

‎docs/ios-port.md‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ translation checks. Later focused native checks are recorded below.
105105
StoreKit coverage uses local simulated transactions; it does not verify production
106106
products or the purchase backend. Advertising checks verify the free bridge,
107107
consent gating, load cancellation, banner layout and paid-impression payloads;
108-
the paid app excludes the SDK classes, resources and metadata. See
109-
[iOS advertising](ios-advertising.md) for source provenance, configuration and
110-
remaining live/device checks.
108+
the paid app excludes the SDK classes, resources and metadata.
111109

112110
The simulator suite currently exercises editor startup, safe-area layout, reading,
113111
editing and saving files, watching coordinated writes, worker loading, incoming
@@ -407,8 +405,8 @@ and cache clearing are supported; clearing the WebView cache keeps app storage.
407405
All sixteen existing app icons are packaged for iPhone and iPad, including Acode's
408406
default artwork. UIKit changes the launcher icon in place. The shared picker
409407
retains reward/Pro requirements and persistence, and omits Android's app-exit
410-
warning on iOS. Reward passes retain the one-hour Quick offer, random four-to-six
411-
hour Focus offer, three-per-day limit and ten-hour cap, with native Keychain state.
408+
warning on iOS. New ad-free passes are discontinued. Existing earned time remains
409+
active until its stored expiry, with native Keychain state preserved.
412410
Native tests verify packaged icon metadata and actual DOM hit targets after
413411
startup. A paid-edition UI test changes and restores the icon through Settings,
414412
acknowledging Apple's confirmation. An iOS-only centering rule keeps WebKit's
@@ -584,9 +582,9 @@ reproduced the missing scene for all six native formats, and all six AdMob bridg
584582
tests pass with the correction. Live portrait and landscape Split View checks
585583
displayed the full interstitial test image and passed dismissal, though other
586584
landscape runs had an unexplained black creative. The iPhone rendered the full
587-
test image, but its dismissal check timed out after desktop UI targeting failures. See
588-
[iOS advertising](ios-advertising.md) for the distinction between these test-ad
589-
checks and production delivery, consent variants and physical-device validation.
585+
test image, but its dismissal check timed out after desktop UI targeting failures.
586+
These test-ad checks do not establish production delivery, consent variants or
587+
physical-device behavior.
590588

591589
## Remaining native work
592590

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "acode-app",
33
"displayName": "Acode",
44
"version": "1.13.6",
5-
"versionCode": 1022,
5+
"versionCode": 1023,
66
"androidPackageId": "com.foxdebug.acode",
77
"appleAppId": "app.acode",
88
"description": "Powerful code editor and terminal for IOS and Android",

‎platforms/android/app/src/free/java/app/acode/ads/AdMob.kt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class AdMob : Service() {
4949
Actions.AD_IS_LOADED to ::executeAdIsLoaded,
5050
Actions.AD_LOAD to ::executeAdLoad,
5151
Actions.AD_SHOW to ::executeAdShow,
52+
Actions.AD_RECOVER_PRESENTATION to ::executeAdRecoverPresentation,
5253
Actions.AD_HIDE to ::executeAdHide,
5354
Actions.PRIVACY_GATHER_CONSENT to privacy::gatherConsent,
5455
Actions.PRIVACY_GET_STATE to privacy::getState,
@@ -177,6 +178,11 @@ class AdMob : Service() {
177178
}
178179
}
179180

181+
private fun executeAdRecoverPresentation(ctx: ExecuteContext) {
182+
val id = ctx.optId() ?: return ctx.reject("id is required")
183+
activity.runOnUiThread { ctx.resolve(recoverAdPresentation(activity, id)) }
184+
}
185+
180186
private fun executeAdHide(ctx: ExecuteContext) {
181187
host!!.activity.runOnUiThread {
182188
ctx.optAdOrReject()?.hide(ctx)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package app.acode.ads
2+
3+
import android.app.Activity
4+
import androidx.lifecycle.Lifecycle
5+
import androidx.lifecycle.LifecycleOwner
6+
import app.acode.ads.ads.Rewarded
7+
8+
internal fun recoverAdPresentation(activity: Activity, id: String): Boolean {
9+
val lifecycle = (activity as? LifecycleOwner)?.lifecycle ?: return false
10+
if (!lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED) ||
11+
!activity.hasWindowFocus() || activity.isFinishing || activity.isDestroyed
12+
) return false
13+
// AdActivity (or an external ad destination) must no longer own the foreground.
14+
val ad = ads[id] ?: return true
15+
if (ad !is Rewarded) return false
16+
ad.onDestroy()
17+
return true
18+
}

0 commit comments

Comments
 (0)