Geo-location in Ionic 2 - ionic-framework

I'm working on Ionic app, which should show users on the map by their current geo-location.
For example, User 1 can turn on GPS, and other Users can see him on
the map after opening a MapComponent. For example, GeoService can fetch current data of the Users's location, on safe it frequently in db (once a minute, for example), and other users, when open MapComponent, can fetch all of data from db collection, and see the Points on the map.
What plugins should I use, or tutorials to archive it? How to get access of the GPS location. How to enable and disable it?

Ionic Native will be a life saver for you.
Ionic Native is a TypeScript wrapper for Cordova/PhoneGap plugins that make adding any native functionality you need to your Ionic mobile app easy.
Geolocation
Depending on how accurate you want the geolocation ping to be and how energy you want it to use you can either go for Background Geolocation (cheap) or Geolocation.
Map Component
In order to display a map with markers on it you should use the Google Maps plugin.
Local Data Cache
You will probably also need a way to cache locally any data you get from the backend (or anything else). The best and easiest way to go about it is using ionic-storage.
Developing using native cordova plugins
In any case, since all these APIs are operating on top of Cordova, you should only test this functionality in an actual device or in an emulator. Of course when geolocation is involved, you cannot go run around the block each time you make a code change so I strongly advise you to mock these plugins during development.

Related

Compare two pictures with each other with Ionic

Is it possible to compare two images with Ionic?
The scenario would be this: I have a database with 50 different images of different flowers and corresponding metadata like title and description. If I now take a picture of a flower with my smartphone, can I assign this picture to another one to find the most suitable result?
Do I need services like the Google Cloud Vision API to do this? Or can I do it internally because I already have the database?
PS: If a server is required, Cloud Functions would be a possibility. For example, programming in Python would be possible there.
No Ionic cannot do this.
Ionic is just a UI framework that allows you to build cross-platform apps and specifically mobile apps (iOS, Android, [formerly] WindowsMobile).
What you're trying to do is something that another system could do. Check out OpenCV,
which would be more suitable for your purposes, and then you can use Ionic to build a nice interface around it.

Can PWA access contacts, gps or use the phone camera?

Can PWA access contacts, gps or use the phone camera?
Is this possible in any system (ios, android) ?
Is there any plan in development to implement any of these features ?
There are some restrictions that cannot be overcome with a PWA:
- you cannot access the contacts list on a phone. - On the other hand, you can take photos and use GPS location.
On whatwebcando.today web site you can have a list of APIs available via browser compared to native apps. If you click on one feature, you can see a sample snippet showing how you can implement it and also details about the browsers support.
UPDATE 30.09.2019
From Chrome v77 there is a new experimental API available: Contact Picker
The Contact Picker API is an on-demand API that allows users to select entries from their contact list and share limited details of the selected entries with a website. It allows users to share only what they want, when they want.
For example, a web-based email client could use the Contact Picker API to select the recipient(s) of an email. A voice-over-IP app could look up which phone number to call.
Hence it might be that the the remaining PWA restrictions will be solved in a near future.
It depends on the device the PWA is running on.
Camera and audio seem to be universally supported. Contacts, on the other hand, seem to be inaccessible regardless of platform.
Other features, such as GPS and geolocation may vary from device to device.
A good way to find out what your browser is capable of (and thus your PWA - it runs in a web browser) is to go to https://whatwebcando.today with the browser you want to support. Try visiting it with an iPhone, Android or other device for a list of enabled features.
This list changes as browser and OS developers increase access to native features, so there's a good change that if it isn't available now, it will be in the future. However, it's important to be aware that some features such as access to the wider file system and hardware configuration are likely to remain sandboxed for security reasons.

Is it possible to activate ionic app on call

I am not sure it is possible in ionic or not. What i want to do is create an app that can record user calls. so app must be activate when user make or get a call.
can anyone tell me if it is possible, how to do this?
Beware this won't be an easy task but "never give up, never surrender". You'll want to use a variation of techniques first off this isn't an Ionic thing as much as it is a PhoneGap thing - ionic runs on phonegap.
Your workflow will look something like this:
User opens your app sees a list of contacts
(the formatted names of contacts are different for android & ios so be prepared to test for this.
http://ngcordova.com/docs/plugins/contacts/)
Contacts are displayed in ion-list user select one and phone's dialer launches (use href=tel:xxxxx)
From there you're going to want to trigger the audio capture plugin's API
https://github.com/apache/cordova-plugin-media-capture
To add the plugin to your project:
cordova plugin add cordova-plugin-media-capture
While it doesn't directly say it can record in call conversations it should still work.
It can definitely be done the storage space is also of concern, you'll have to set something in place to tell the user how many seconds/minutes they have the capacity to store.
That should get you started there will certainly be unforeseen nuances.
Good luck.
We can record calls with cordova-media-plugin plugin in android.
First install the media Plugin by executing the following command
cordova plugin add cordova-plugin-media
Then goto the Plugin folder and traverse into the following file “plugins\cordova-plugin-media\src\android\AudioPlayer.java” . Here in the startRecording function we have line
this.recorder.setAudioSource(MediaRecorder.AudioSource.MIC); line number is 154
Change it to this.recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
We can replace MIC with any audio source in the following link. for example VOICE_COMMUNICATION,VOICE_DOWNLINK,VOICE_RECOGNITION etc
https://developer.android.com/reference/android/media/MediaRecorder.AudioSource.html

how to create customer map on iPhone without using Google Map

I'm trying to integrated in our iOS app. Due to the bad relationship between Google & our government, Google Map is not a good idea.
We have bought a local map service company's javascript & Web Services based SDK, now we want to use it on iOS. But it seems that MapKit does not support customer tiles.
So here are my current ideas:
Use UIWebView. But I tried that map in Safari, I can't drag to move the map nor use two fingers to zoom. I think I need to call some javascripts while touch events happens.
Build a costumer UIScrollView, download map images and display them using iOS sdk. But that map service does not have API to download images, I tried to read their 200KB+ undocumented javascript to find out the relationship between location & image files, but I got no results for now.
Both the two ways could face certain legal risks. I'm not sure what the purchase contract is like.
I need suggestions about the two ways or some new ideas. Thanks guys.
There are a couple of non-Google map implementations available on github that you might be able to use (linked via CocoaControls):
NAMapKit
MRMapView

Force MapKit use cached map tiles only/disable network programmatically

We have stumbled upon such a problem.
We are developing an application for travelling. To make sure the user doesn't spend much money on roaming charges in our app we decided to implement a settings option for user to view cached maps only. So we let the user decide whether he wants to load the maps from internet or he wants to save money and view cached maps (stored in Library/Caches/MapTiles/MapTiles.sqlitedb).
We can't find a way to implement this. Is there any way to disable network programmatically in this case? Or force MapKit use cached tiles only? We thought about changing APN programmatically for this option to force MapKit go offline. Is it possible to change APN programmatically?
Thank you!
iPhone SDK apps do not have access to the network adapter settings, and I know of nothing in the MapKit API that gives you control over its Internet usage. Your best option in this case is probably to present an alert suggesting that the user enable Airplane Mode or turn off data roaming.
use openstreetmap
think the commercial side of it Cloud-made allows offline maps
http://developers.cloudmade.com/projects/show/iphone-sdk
Libraries that help iPhone developers use OSM maps
route-me is an open-source library used in a number of iPhone applications to display OSM maps.
The CloudMade iPhone Maps Library is an open-source library that provides high-level access to CloudMade's OSM-based map tiles with different sizes and different styles.
John McKerrell has ported the routing algorithm from gosmore to run on the iPhone and has successfully generated basic routes. More complicated routes crash the iPhone at the moment
There are some ways. One is to use your own tile overlay and implement the caching algorithm either in URLForTilePath: or in loadTileAtPath:result:
It works very well with open domain and some private ones. Does not cache the standard Apple Maps.
Another way that will be able to cache everything is subclass NSURLProtocol. There are some tutorials and probably you may detect when is a map image and act accordingly
the google map app does the cache feature ... MapKit seem no , I think Apple will add this feature in next version SDK ...