Skip to content

Commit

Permalink
fix(ios): enable donations through in app purchase
Browse files Browse the repository at this point in the history
  • Loading branch information
farfromrefug committed Jan 7, 2025
1 parent c0efcb8 commit 837fa69
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 7 deletions.
5 changes: 5 additions & 0 deletions app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ try {
DrawerElement.register();
startSentry();
initialize({ isDownsampleEnabled: true });

if (PLAY_STORE_BUILD) {
import('@shared/utils/inapp-purchase').then((r) => r.init());
}

// Trace.addCategories(Trace.categories.Navigation);
// Trace.addCategories(Trace.categories.Transition);
// Trace.addCategories(Trace.categories.Accessibility);
Expand Down
26 changes: 22 additions & 4 deletions app/components/settings/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import { colors, fonts, hasCamera, windowInset } from '~/variables';
import IconButton from '../common/IconButton.svelte';
import { share } from '@akylas/nativescript-app-utils/share';
import { inappItems, presentInAppSponsorBottomsheet } from '@shared/utils/inapp-purchase';
const version = __APP_VERSION__ + ' Build ' + __APP_BUILD_NUMBER__;
const storeSettings = {};
const variant = 'outline';
Expand All @@ -85,6 +86,8 @@
let items: ObservableArray<any>;
const inAppAvailable = PLAY_STORE_BUILD && inappItems?.length > 0;
export let title = null;
export let actionBarButtons = [
{ icon: 'mdi-share-variant', id: 'share' },
Expand Down Expand Up @@ -517,7 +520,7 @@
[
{
type: 'header',
title: __IOS__ ? lc('show_love') : lc('donate')
title: __IOS__ && !inAppAvailable ? lc('show_love') : lc('donate')
},
{
type: 'sectionheader',
Expand Down Expand Up @@ -959,9 +962,24 @@
openLink(STORE_REVIEW_LINK);
break;
case 'sponsor':
// Apple wants us to use in-app purchase for donations => taking 30% ...
// so lets just open github and ask for love...
openLink(__IOS__ ? GIT_URL : SPONSOR_URL);
switch (item.type) {
case 'librepay':
openLink('https://liberapay.com/farfromrefuge');
break;
case 'patreon':
openLink('https://patreon.com/farfromrefuge');
break;
default:
if (inAppAvailable) {
presentInAppSponsorBottomsheet();
} else {
// Apple wants us to use in-app purchase for donations => taking 30% ...
// so lets just open github and ask for love...
openLink(__IOS__ ? GIT_URL : SPONSOR_URL);
}
break;
}
break;
case 'third_party':
const ThirdPartySoftwareBottomSheet = (await import('~/components/settings/ThirdPartySoftwareBottomSheet.svelte')).default;
Expand Down
12 changes: 12 additions & 0 deletions app/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@
"import_settings_desc": "import all settings from a previous backup",
"imported_nb_pages": "imported %1$s pages",
"internal_storage": "internal storage",
"inapp":{
"smalltip": "a coffee",
"smalltip_desc": "everything helps to work at night!",
"mediumtip": "a big coffee",
"mediumtip_desc": "my eyes are open!",
"largetip": "a beer",
"largetip_desc": "chill out and go back to work!",
"largertip": "a pint",
"largertip_desc": "ideas are going to flow!",
"bigtip": "a very nice donation",
"bigtip_desc": "new features are coming!"
},
"invalid": "invalid",
"ios": {
"info": {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@akylas/nativescript": "8.8.10",
"@akylas/nativescript-app-tools": "file:tools",
"@akylas/nativescript-app-utils": "2.2.1",
"@akylas/nativescript-inapp-purchase": "^0.0.3",
"@akylas/nativescript-inappbrowser": "3.1.8",
"@akylas/panzoom": "4.6.0",
"@mdi/font": "7.4.47",
Expand Down
2 changes: 1 addition & 1 deletion tools
12 changes: 10 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ __metadata:

"@akylas/nativescript-app-tools@file:tools::locator=root-workspace-0b6124%40workspace%3A.":
version: 1.0.0
resolution: "@akylas/nativescript-app-tools@file:tools#tools::hash=96949e&locator=root-workspace-0b6124%40workspace%3A."
resolution: "@akylas/nativescript-app-tools@file:tools#tools::hash=0a5721&locator=root-workspace-0b6124%40workspace%3A."
dependencies:
"@dotenvx/dotenvx": "npm:1.28.0"
"@nativescript-community/fontmin": "npm:0.9.11"
Expand Down Expand Up @@ -82,7 +82,7 @@ __metadata:
typescript: "npm:5.7.2"
typescript-eslint: "npm:^8.17.0"
webpack-bundle-analyzer: "npm:^4.10.2"
checksum: 10/5942d622caaeed385f8bbc1d0ab9708355fae7dadd62b45f7f2e24156f8ef59afea6e0bb478a6fa50b08fb47b8a2a8dccdb08d035c8768154fd7f654a1be7cf8
checksum: 10/925fdd661d7197b173a3f493fb313d69ccf8ab9b279a34d69887ed4a416780f7cefdba0174e1cb3c8ce7a48038e6ded27c4192593b4b7a31684fcf659afb35d9
languageName: node
linkType: hard

Expand All @@ -95,6 +95,13 @@ __metadata:
languageName: node
linkType: hard

"@akylas/nativescript-inapp-purchase@npm:^0.0.3":
version: 0.0.3
resolution: "@akylas/nativescript-inapp-purchase@npm:0.0.3"
checksum: 10/5578732a7f026fb90be78ee26e41665f734a1d051a322f8a1f085203be18e482efee177cc908f680238dc7dcd0ef4523f2c24418d745e5943332937d226d4a9c
languageName: node
linkType: hard

"@akylas/nativescript-inappbrowser@npm:3.1.8":
version: 3.1.8
resolution: "@akylas/nativescript-inappbrowser@npm:3.1.8"
Expand Down Expand Up @@ -10376,6 +10383,7 @@ __metadata:
"@akylas/nativescript-android-runtime": "npm:8.8.5"
"@akylas/nativescript-app-tools": "file:tools"
"@akylas/nativescript-app-utils": "npm:2.2.1"
"@akylas/nativescript-inapp-purchase": "npm:^0.0.3"
"@akylas/nativescript-inappbrowser": "npm:3.1.8"
"@akylas/nativescript-ios-runtime": "npm:8.8.2"
"@akylas/nativescript-webpack": "npm:5.0.22"
Expand Down

0 comments on commit 837fa69

Please sign in to comment.