DeveloperBreeze

Modern Web Apis Development Tutorials, Guides & Insights

Unlock 1+ expert-curated modern web apis tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your modern web apis skills on DeveloperBreeze.

Building Progressive Web Apps (PWAs) with Modern APIs

Tutorial August 05, 2024
json bash

function getLocation() {
  if ('geolocation' in navigator) {
    navigator.geolocation.getCurrentPosition(position => {
      console.log('Latitude:', position.coords.latitude);
      console.log('Longitude:', position.coords.longitude);
    });
  } else {
    console.log('Geolocation is not supported by this browser.');
  }
}

getLocation();
function shareContent() {
  if (navigator.share) {
    navigator.share({
      title: 'My PWA',
      text: 'Check out my Progressive Web App!',
      url: window.location.href
    }).then(() => {
      console.log('Content shared successfully!');
    }).catch(error => {
      console.error('Error sharing content:', error);
    });
  } else {
    console.log('Web Share API is not supported in this browser.');
  }
}

shareContent();