Application sharing

Hi! I’ve been trying to use Social Sharing, and this is my code:

import { Component } from '@angular/core';
import { SocialSharing } from '@ionic-native/social-sharing/ngx';

@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})
export class HomePage {
  text = 'Check this out moron';
  url = 'https://ionicacademy.com';

  constructor(private socialSharing: SocialSharing) { }

  shareEmail() {
    this.socialSharing.canShareViaEmail().then(() => {
      // Sharing via email is possible
    }).catch((e) => {
      console.log(e);
      
      // Sharing via email is not possible
    });


    // Share via email
    this.socialSharing.shareViaEmail('Body', 'Subject', ['recipient@example.org']).then(() => {
      // Success!
    }).catch((e) => {
      console.log(e);
      
      // Error!
    });
  }

  shareWhatsApp(){
    this.socialSharing.shareViaWhatsApp(this.text, null, this.url).then(()=> {

    }).catch(e => {
      console.log(e);
      
    })
  }

}

In my code, I put the url is for the ionicacademy website, is it possible to replace the url as the current page of my app?

I’m also facing the same problem, did you find the solution yet?

1 Like

yeah if you have well routed your page. https://angular.io/guide/router
will help you to route your pages