Fix: Application stuck in splash screen after install google maps native
Check the environment at the app starting time even on iOS
MODIFY
src/ios/GoogleMaps/Environment.m
src/ios/GoogleMaps/Environment.m
@@ -24,7 +24,40 @@ dispatch_queue_t queue;
- (void)isAvailable:(CDVInvokedUrlCommand *)command {
// Return true always in iOS.
dispatch_async(queue, ^{
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ //-------------------------------
+ // Check the Google Maps API key
+ //-------------------------------
+ NSString *errorMsg = nil;
+ NSString *APIKey = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"Google Maps API Key"];
+ if (!APIKey) {
+ errorMsg = [PluginUtil PGM_LOCALIZATION:@"APIKEY_IS_UNDEFINED_MESSAGE"];
+ } else {
+
+ /*---------------------------------------------------------------------------------------
+ * If CFBundleExecutable is not English, the Google Maps SDK for iOS will crash.
+ * So must be English.
+ *
+ * If you want to use non-english name for your app, you need to change your config.xml like this.
+ *
+ * <?xml version='1.0' encoding='utf-8'?>
+ * <widget id="(package name)" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+ * <name short="(non-english app name)">(english app name)</name>
+ *---------------------------------------------------------------------------------------*/
+
+ NSDictionary *info = [[NSBundle mainBundle] infoDictionary];
+ NSString *CFBundleExecutable = [info objectForKey:@"CFBundleExecutable"];
+
+ NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^[a-zA-Z0-9$@$!%*?&#^-_.\\s+]+$" options:NSRegularExpressionCaseInsensitive error:nil];
+ if ([regex numberOfMatchesInString:CFBundleExecutable options:0 range:NSMakeRange(0, CFBundleExecutable.length)] == 0) {
+ errorMsg = [PluginUtil PGM_LOCALIZATION:@"APP_NAME_ERROR_MESSAGE"];
+ }
+ }
+ CDVPluginResult* pluginResult;
+ if (errorMsg) {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:errorMsg];
+ } else {
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ }
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
});

MODIFY
www/googlemaps-cdv-plugin.js
www/googlemaps-cdv-plugin.js
@@ -18,22 +18,17 @@ if (!cordova) {
window.plugin = window.plugin || {};
window.plugin.google = window.plugin.google || {};
window.plugin.google.maps = window.plugin.google.maps || module.exports;
+
+
document.addEventListener("deviceready", function() {
// workaround for issue on android-19: Cannot read property 'maps' of undefined
if (!window.plugin) { console.warn('re-init window.plugin'); window.plugin = window.plugin || {}; }
if (!window.plugin.google) { console.warn('re-init window.plugin.google'); window.plugin.google = window.plugin.google || {}; }
if (!window.plugin.google.maps) { console.warn('re-init window.plugin.google.maps'); window.plugin.google.maps = window.plugin.google.maps || module.exports; }
- // Check the Google Maps Android API v2 if the device platform is Android.
- if (/Android/i.test(window.navigator.userAgent)) {
- //------------------------------------------------------------------------
- // If Google Maps Android API v2 is not available,
- // display the warning alert.
- //------------------------------------------------------------------------
cordova.exec(null, function(message) {
alert(message);
}, 'Environment', 'isAvailable', ['']);
- }
}, {
once: true
});
@@ -85,9 +80,10 @@ if (!cordova) {
cordovaGoogleMaps.followMapDivPositionOnly.call(cordovaGoogleMaps);
}, true);
-
- onScrollEnd();
+ common.nextTick(onScrollEnd);
});
+ }, {
+ once: true
});
/*****************************************************************************

- Fix: Application stuck in splash screen after install google maps native #2191
- Check the environment at the app starting time even on iOS