Giter Site home page Giter Site logo

sms-link's Introduction

SMS Link

Make SMS links compatible cross devices, without any other dependancies.

The problem

In the world of SMS URLs, iOS is making our life hard.

The standard way to write an SMS link in HTML is this one:

<a href="sms:+33102030405?body=Body Content">Your link text</a>

This thing is, depending on which version of iOS you use, the ? separator must be changed to either a ; or a &.

This library detect which version you're running and adapt the links accordingly.

How to use

Include sms-link.min.js and put a link in your html.

<a href="sms:+33102030405?body=Body Content">Your link text</a>

Then just call the class in JavaScript

document.addEventListener('DOMContentLoaded', (function () {
    link = new SMSLink.link();
    link.replaceAll();
}), false);

API

SMSLink.detector

This class is used to detect version of mobile OSes.

Only Android and iOS are detected.

It exposes various method :

  • os : return either iOS or Android or null if nothing has been detected
  • version : return the found version or null if nothing had been detected
  • isMobile: return true if the OS has been detected

SMSLink.link

This class replace the links with correct URLS.

Methods:

  • replace : Replace the href attribute to match the correct format used by the OS.
  • replaceWithSelector : Call the replace method on all matching elements
  • replaceAll : Replace all "sms:" url to a correct version.

License

This code is in Public Domain, so do anything you want with it.

The SMSLink.detector code is inspired by a StackOverflow post, so I guess it's under the MIT licence, anyway you'll find a link in the source code.

sms-link's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sms-link's Issues

press button

when the link is pressed how to press send button on the mobile automatically

iOS No Longer supports "body"

FYI iOS compatibility has removed the 'body' parameter.

"""
The sms scheme is used to launch the Messages app. The format for URLs of this type is โ€œsms:โ€, where is an optional parameter that specifies the target phone number of the SMS message. This parameter can contain the digits 0 through 9 and the plus (+), hyphen (-), and period (.) characters. The URL string must not include any message text or other information.
"""

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.