[internals][utils] added play services red box string creator

This commit is contained in:
Salakar 2017-10-07 03:06:29 +01:00
parent 1d2549556b
commit 11da976a0a
1 changed files with 63 additions and 4 deletions

View File

@ -22,10 +22,43 @@ const GRADLE_DEPS = {
admob: 'ads', admob: 'ads',
}; };
const PLAY_SERVICES_CODES = {
1: {
code: 'SERVICE_MISSING',
message: 'Google Play services is missing on this device.',
},
2: {
code: 'SERVICE_VERSION_UPDATE_REQUIRED',
message: 'The installed version of Google Play services on this device is out of date.',
},
3: {
code: 'SERVICE_DISABLED',
message: 'The installed version of Google Play services has been disabled on this device.',
},
9: {
code: 'SERVICE_INVALID',
message: 'The version of the Google Play services installed on this device is not authentic.',
},
18: {
code: 'SERVICE_UPDATING',
message: 'Google Play services is currently being updated on this device.',
},
19: {
code: 'SERVICE_MISSING_PERMISSION',
message: 'Google Play service doesn\'t have one or more required permissions.',
},
};
export default { export default {
// default options // default options
OPTIONS: { OPTIONS: {
logLevel: 'warn', logLevel: 'warn',
errorOnMissingPlayServices: true,
promptOnMissingPlayServices: true,
},
FLAGS: {
checkedPlayServices: false,
}, },
// track all initialized firebase apps // track all initialized firebase apps
@ -141,15 +174,15 @@ export default {
/** /**
* @return {string} * @return {string}
*/ */
ERROR_UNSUPPORTED_CLASS_METHOD(classname, method) { ERROR_UNSUPPORTED_CLASS_METHOD(className, method) {
return `${classname}.${method}() is unsupported by the native Firebase SDKs.`; return `${className}.${method}() is unsupported by the native Firebase SDKs.`;
}, },
/** /**
* @return {string} * @return {string}
*/ */
ERROR_UNSUPPORTED_CLASS_PROPERTY(classname, property) { ERROR_UNSUPPORTED_CLASS_PROPERTY(className, property) {
return `${classname}.${property} is unsupported by the native Firebase SDKs.`; return `${className}.${property} is unsupported by the native Firebase SDKs.`;
}, },
/** /**
@ -159,6 +192,32 @@ export default {
return `firebase.${module._NAMESPACE}().${method}() is unsupported by the native Firebase SDKs.`; return `firebase.${module._NAMESPACE}().${method}() is unsupported by the native Firebase SDKs.`;
}, },
/**
* @return {string}
*/
ERROR_PLAY_SERVICES(statusCode) {
const knownError = PLAY_SERVICES_CODES[statusCode];
let start = 'Google Play Services is required to run firebase services on android but a valid installation was not found on this device.';
if (statusCode === 2) {
start = 'Google Play Services is out of date and may cause some firebase services like authentication to hang when used. It is recommended that you update it.';
}
// eslint-disable-next-line prefer-template
return `${start}\r\n\r\n` +
'-------------------------\r\n' +
(knownError ?
`${knownError.code}: ${knownError.message} (code ${statusCode})` :
`A specific play store availability reason reason was not available (unknown code: ${statusCode || null})`
) +
'\r\n-------------------------' +
'\r\n\r\n' +
'For more information on how to resolve this issue, configure Play Services checks or for guides on how to validate Play Services on your users devices see the link below:' +
'\r\n\r\nhttp://invertase.link/play-services';
},
DEFAULT_APP_NAME, DEFAULT_APP_NAME,
}, },