souzadriano / ionic2-google-places-autocomplete

Other
8 stars 5 forks source link

Does not work on real iphone #5

Open Alb93 opened 6 years ago

Alb93 commented 6 years ago

The list of the locations is not shown and no errors were thrown in xcode. With Android it works.

Some help for iOS?

souzadriano commented 6 years ago

The component don't use iOS native code, it's only html and ionic (angular) requests to Google WebServer. I don't have now a real iPhone to test, I will test on iOS simulator on mac. What are the parameters you use and the ionic version?

Alb93 commented 6 years ago

I know the plugin is an Angular module but for some reasons it is not working for iOS (I've tested also with the simulator).

I'm using it with <google-places-autocomplete types="(cities)" [placeholder]="placeholder" (callback)="detail($event[0])" key="my-private-key"></google-places-autocomplete>

No problem for Android I repeat, but it does nothing with iOS, at least in my case.

The Ionic version is 3.8.0 `

Alb93 commented 6 years ago

It is a problem related to the new WKWEBVIEW. My solution is to use cordova-plugin-http with a particular care of white spaces (it crashes in iOS in that case) and to rewrite the component with that plugin.

See https://ionicframework.com/docs/wkwebview/ also

souzadriano commented 6 years ago

Thank you @Alb93 I read the link that you sended and the new WKWEBVIEW have new CORS politics. I will try fix the problem with you suggestions.

jlt0022 commented 6 years ago

Great plugin! Any news on this particular bug?

souzadriano commented 6 years ago

Hi jlt0022,

I'm trying to find a solution, but the google places don't support jsonp. I will try add cordova-plugin-http.

For now you can do downgrade of ios webview: https://ionicframework.com/docs/wkwebview/#downgrading-to-uiwebview

jlt0022 commented 6 years ago

Gotcha, that makes sense. Any idea what this error means? Something is happening with the call back of the function "detail"

[Error] ERROR TypeError: _co.detail is not a function. (In '_co.detail($event[0])', '_co.detail' is undefined) error View_SettingsPage_0 (SettingsPage.ngfactory.js:231) logError (vendor.js:14045) (anonymous function) handleError (vendor.js:1699) handleError (vendor.js:137512) (anonymous function) (vendor.js:11406) (anonymous function) (vendor.js:4266) __tryOrUnsub (vendor.js:16456) next (vendor.js:16403) _next (vendor.js:16343) next (vendor.js:16307) next (vendor.js:19817) emit (vendor.js:4240) detail (vendor.js:84021) (anonymous function) (GooglePlacesAutocompleteComponent.ngfactory.js:11) callWithDebugContext (vendor.js:14105) (anonymous function) (vendor.js:9845) (anonymous function) (vendor.js:38133) onInvokeTask (vendor.js:4500) runTask (polyfills.js:3:10225) invokeTask (polyfills.js:3:16182) p (polyfills.js:2:27000) v (polyfills.js:2:27240)

souzadriano commented 6 years ago

detail is the callback method with response from google places. Implement the method in controller like this:

    export class HomePage {

          constructor(public navCtrl: NavController) {
          }

          detail(item) {
            console.log(item);
          }

     }

PS.: detail is only example, you can change the name