Skip to content

Commit

Permalink
Re-Added email plugin for Android
Browse files Browse the repository at this point in the history
- Issues with socialSharing, `loggerDB` file, and Gmail App
- Because Gmail is default mail on Android, we want to make sure it works
- Reverting to old plugin to make sure this sends correctly
- Tested and confirmed send works on iOS & Android Hardware
- Please see PR for further details
  • Loading branch information
the-bay-kay committed May 22, 2024
1 parent f25a2e9 commit 3e0ddb8
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 28 deletions.
2 changes: 2 additions & 0 deletions package.cordovabuild.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"ANDROID_HOST": " ",
"ANDROID_PATHPREFIX": "/"
},
"cordova-plugin-email-composer": {},
"cordova-plugin-x-socialsharing": {
"PHOTO_LIBRARY_ADD_USAGE_DESCRIPTION": "This app requires photo library access to share photos on social media.",
"PHOTO_LIBRARY_USAGE_DESCRIPTION": "This app requires photo library access to share photos on social media."
Expand Down Expand Up @@ -127,6 +128,7 @@
"cordova-plugin-em-settings": "git+https://github.com/e-mission/cordova-connection-settings.git#v1.2.3",
"cordova-plugin-em-unifiedlogger": "git+https://github.com/e-mission/cordova-unified-logger.git#v1.3.6",
"cordova-plugin-em-usercache": "git+https://github.com/e-mission/cordova-usercache.git#v1.1.9",
"cordova-plugin-email-composer": "git+https://github.com/katzer/cordova-plugin-email-composer.git#0.10.1",
"cordova-plugin-file": "8.0.0",
"cordova-plugin-inappbrowser": "5.0.0",
"cordova-plugin-ionic-keyboard": "2.2.0",
Expand Down
60 changes: 40 additions & 20 deletions www/js/services/shareLocalDBFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,55 @@ export async function sendLocalDBFile(database: string) {

if (window['cordova'].platformId == 'android') {
parentDir = 'app://databases';
logInfo('Going to email ' + database);

Check warning on line 9 in www/js/services/shareLocalDBFile.ts

View check run for this annotation

Codecov / codecov/patch

www/js/services/shareLocalDBFile.ts#L8-L9

Added lines #L8 - L9 were not covered by tests

parentDir = parentDir + '/' + database;

Check warning on line 11 in www/js/services/shareLocalDBFile.ts

View check run for this annotation

Codecov / codecov/patch

www/js/services/shareLocalDBFile.ts#L11

Added line #L11 was not covered by tests

const emailData = {

Check warning on line 13 in www/js/services/shareLocalDBFile.ts

View check run for this annotation

Codecov / codecov/patch

www/js/services/shareLocalDBFile.ts#L13

Added line #L13 was not covered by tests
to: '[email protected]',
attachments: [parentDir],
subject: i18next.t('shareFile-service.send-log.body-please-fill-in-what-is-wrong'),
body: i18next.t('shareFile-service.send-log.subject-logs'),
};

alert(i18next.t('shareFile-service.send-to'));

Check warning on line 20 in www/js/services/shareLocalDBFile.ts

View check run for this annotation

Codecov / codecov/patch

www/js/services/shareLocalDBFile.ts#L20

Added line #L20 was not covered by tests

// Gmail app has issues attatching `loggerDB` file when using the `socialSharing`
// plugin. As such, we'll keep using this plugin for Android - since GMail is
// the default on Android, we want to support this!
window['cordova'].plugins['email'].open(emailData, () => {
logWarn(`Email app closed while sending,

Check warning on line 26 in www/js/services/shareLocalDBFile.ts

View check run for this annotation

Codecov / codecov/patch

www/js/services/shareLocalDBFile.ts#L25-L26

Added lines #L25 - L26 were not covered by tests
emailData = ${JSON.stringify(emailData)}`);
});
}

if (window['cordova'].platformId == 'ios') {
logDebug(window['cordova'].file.dataDirectory);
parentDir = window['cordova'].file.dataDirectory + '../LocalDatabase';

Check warning on line 33 in www/js/services/shareLocalDBFile.ts

View check run for this annotation

Codecov / codecov/patch

www/js/services/shareLocalDBFile.ts#L32-L33

Added lines #L32 - L33 were not covered by tests

logInfo('Going to email ' + database);
parentDir = parentDir + '/' + database;

Check warning on line 36 in www/js/services/shareLocalDBFile.ts

View check run for this annotation

Codecov / codecov/patch

www/js/services/shareLocalDBFile.ts#L35-L36

Added lines #L35 - L36 were not covered by tests

const shareObj = {

Check warning on line 38 in www/js/services/shareLocalDBFile.ts

View check run for this annotation

Codecov / codecov/patch

www/js/services/shareLocalDBFile.ts#L38

Added line #L38 was not covered by tests
files: [parentDir],
message: i18next.t('shareFile-service.send-log.body-please-fill-in-what-is-wrong'),
subject: i18next.t('shareFile-service.send-log.subject-logs'),
};

alert(i18next.t('shareFile-service.send-to'));
window['plugins'].socialsharing.shareWithOptions(

Check warning on line 45 in www/js/services/shareLocalDBFile.ts

View check run for this annotation

Codecov / codecov/patch

www/js/services/shareLocalDBFile.ts#L44-L45

Added lines #L44 - L45 were not covered by tests
shareObj,
(result) => {
logDebug(`Shared to app: ${result.app}`);

Check warning on line 48 in www/js/services/shareLocalDBFile.ts

View check run for this annotation

Codecov / codecov/patch

www/js/services/shareLocalDBFile.ts#L47-L48

Added lines #L47 - L48 were not covered by tests
},
(err) => {
logWarn(`Sharing failed with error: ${err}`);

Check warning on line 51 in www/js/services/shareLocalDBFile.ts

View check run for this annotation

Codecov / codecov/patch

www/js/services/shareLocalDBFile.ts#L50-L51

Added lines #L50 - L51 were not covered by tests
},
);
}

if (parentDir == 'unknown') {
displayErrorMsg('parentDir unexpectedly = ' + parentDir + '!');
return;

Check warning on line 58 in www/js/services/shareLocalDBFile.ts

View check run for this annotation

Codecov / codecov/patch

www/js/services/shareLocalDBFile.ts#L57-L58

Added lines #L57 - L58 were not covered by tests
}

logInfo('Going to email ' + database);
parentDir = parentDir + '/' + database;

const shareObj = {
files: [parentDir],
message: i18next.t('shareFile-service.send-log.body-please-fill-in-what-is-wrong'),
subject: i18next.t('shareFile-service.send-log.subject-logs'),
};

alert(i18next.t('shareFile-service.send-to'));
window['plugins'].socialsharing.shareWithOptions(
shareObj,
(result) => {
logDebug(`Shared to app: ${result.app}`);
},
(err) => {
logWarn(`Sharing failed with error: ${err}`);
},
);
}
16 changes: 8 additions & 8 deletions www/js/usePermissionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ const usePermissionStatus = () => {
androidVersion < 6
? 'intro.appstatus.locperms.description.android-lt-6'
: androidVersion < 10
? 'intro.appstatus.locperms.description.android-6-9'
: androidVersion < 11
? 'intro.appstatus.locperms.description.android-10'
: androidVersion < 12
? 'intro.appstatus.locperms.description.android-11'
: 'intro.appstatus.locperms.description.android-gte-12';
? 'intro.appstatus.locperms.description.android-6-9'

Check warning on line 139 in www/js/usePermissionStatus.ts

View check run for this annotation

Codecov / codecov/patch

www/js/usePermissionStatus.ts#L139

Added line #L139 was not covered by tests
: androidVersion < 11
? 'intro.appstatus.locperms.description.android-10'

Check warning on line 141 in www/js/usePermissionStatus.ts

View check run for this annotation

Codecov / codecov/patch

www/js/usePermissionStatus.ts#L141

Added line #L141 was not covered by tests
: androidVersion < 12
? 'intro.appstatus.locperms.description.android-11'
: 'intro.appstatus.locperms.description.android-gte-12';

Check warning on line 144 in www/js/usePermissionStatus.ts

View check run for this annotation

Codecov / codecov/patch

www/js/usePermissionStatus.ts#L143-L144

Added lines #L143 - L144 were not covered by tests
logDebug('description tags are ' + androidSettingsDescTag + ' ' + androidPermDescTag);
// location settings
let locSettingsCheck = {
Expand Down Expand Up @@ -392,8 +392,8 @@ const usePermissionStatus = () => {
androidVersion == 12
? 'intro.appstatus.unusedapprestrict.description.android-disable-12'
: androidVersion < 12
? 'intro.appstatus.unusedapprestrict.description.android-disable-lt-12'
: 'intro.appstatus.unusedapprestrict.description.android-disable-gte-13';
? 'intro.appstatus.unusedapprestrict.description.android-disable-lt-12'
: 'intro.appstatus.unusedapprestrict.description.android-disable-gte-13';

Check warning on line 396 in www/js/usePermissionStatus.ts

View check run for this annotation

Codecov / codecov/patch

www/js/usePermissionStatus.ts#L395-L396

Added lines #L395 - L396 were not covered by tests
let unusedAppsUnrestrictedCheck = {
name: t('intro.appstatus.unusedapprestrict.name'),
desc: t(androidUnusedDescTag),
Expand Down

0 comments on commit 3e0ddb8

Please sign in to comment.