Google places api error in ionic


#1

I am using google places api in ionic app.I places google places api script in index.html. The app allow the user to access wifi within specific place. User get internet access after login with our app. When application launch and user is connecting with our network, user do not have access to the internet. So i get error:

Application Error connection to the server was unsuccessful.

Is there anyway to call the google places api after user has access to the internet to avoid the error?


#2

You can try adding async defer

<script async defer src="googleapis.com...etc"></script>

#3

I already try it, but the in this case i get error: google is undefined


#4

in your component, are you declaring var google?
i.e,

import { Component } from 'xxx';
declare var google;

@Component({
selector: 'xx',
templateUrl: 'xx'
})
export class MapPage {
}

#5

Yes, i did. i declare var google.


#6

hmm. I’m in the process of moving the next couple days, but when I get a chance after that I’ll post the entirety of my code for you, either here or i’ll get you the link to my git repository. It’s fully operational.


#7

When application launch and user is connecting with our network, user do not have access to the internet. So i get error. Do you know how to tackle this situation?


#8

It may be an issue of activating your service worker in index.html. But, that’s out of my league. I don’t know a whole lot about that subject, sorry.


#9

This issue has been solved. The link to the answer is given below: