I have two buttons in my app one for open gmail and other one for open map with latitude and longitude but both methods are not working in mu ionic app


#1

this is the method for open gmail

mailto()
{
this.platform.ready().then(() =>
{

	  if (this.platform.is('ios')) 
	{
			window.open('googlegmail:///co?to='+this.email+'&subject='+'subject'+'&body=','_system');
			
	};
	  if (this.platform.is('android'))
	{
	      window.open('mailto:'+this.email);

	};

});
}

//and this is for opem map in ionic

locationOpen()
{

this.platform.ready().then(() => {
   this.geolocation.getCurrentPosition().then((position) => 
   {
    // ios
    if (this.platform.is('ios')) 
	{
      window.open('maps://?q=' + this.address + '&saddr=' + position.coords.latitude + ',' + position.coords.longitude + '&daddr=' + this.lat + ',' + this.longe, '_system','location=yes');
    };
    // android
    if (this.platform.is('android'))
	{
      window.open('geo://' + position.coords.latitude + ',' + position.coords.longitude + '?q=' + this.lat+ ',' + this.longe + '(' + this.address+ ')', '_system');
    };
  });
});

}

please any one can help me i tried all logic from google.


#2

https://ionicframework.com/docs/native/launch-navigator/ try this plugin for maps
https://ionicframework.com/docs/native/email-composer/ this is for email
// add alias
this.email.addAlias(‘gmail’, ‘com.google.android.gm’);

// then use alias when sending email
this.email.open({
app: ‘gmail’,

});


#3

I tried your suggestion but it’s still not working

mailto()
{

this.emailComposer.addAlias(‘gmail’, ‘com.google.android.gm’);

// then use alias when sending email
this.emailComposer.open({
app: ‘gmail’,

});

/*
this.platform.ready().then(() =>
{

	  if (this.platform.is('ios')) 
	{
			window.open('googlegmail:///co?to='+this.email,'_system');
			
	};
	  if (this.platform.is('android'))
	{
	      window.open('mailto:'+this.email);

	};

});

*/
}

locationOpen()
{

this.platform.ready().then(() => {
   this.geolocation.getCurrentPosition().then((position) => 
   {
   
   let options: LaunchNavigatorOptions = {

start: ‘London, ON’,
app: LaunchNavigator.APPS.MAPS
};

this.launchNavigator.navigate(‘Toronto, ON’, options)
.then(
success => console.log(‘Launched navigator’),
error => console.log(‘Error launching navigator’, error)
);

/*   
   
    // ios
    if (this.platform.is('ios')) 
	{
      window.open('maps://?q=' + this.address + '&saddr=' + position.coords.latitude + ',' + position.coords.longitude + '&daddr=' + this.lat + ',' + this.longe, '_system','location=yes');
    };
    // android
    if (this.platform.is('android'))
	{
      window.open('geo://' + position.coords.latitude + ',' + position.coords.longitude + '?q=' + this.lat+ ',' + this.longe + '(' + this.address+ ')', '_system');
    };
  });
});

*/

}


#4

Can any one help me out for send email from ionic app in ios platform

if (this.platform.is(‘ios’))
{
window.open(‘googlegmail:///co?to=’+this.email+’&subject=’+‘subject’+’&body=’,’_system’);

};
  if (this.platform.is('android'))
{
      window.open('mailto:'+this.email);

};

I am using this code for send email. Its working fine on android but not working in ios .