Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helper method to create an sms link #36511

Merged
merged 2 commits into from Jul 19, 2019
Merged

Conversation

@aantix
Copy link
Contributor

@aantix aantix commented Jun 17, 2019

When the user clicks the sms link, the user's messaging software is opened with the passed in phone number and optional body value prepopulated.

Test page :
https://sms-to-rails-test.herokuapp.com/

<%= sms_to "15155555785", "Text me", body: "I have a question.." %>

Summary

OSX Chrome/Safari
image

Android
image

iOS Safari
image

@rails-bot rails-bot bot added the actionview label Jun 17, 2019
@guilleiguaran
Copy link
Member

@guilleiguaran guilleiguaran commented Jun 18, 2019

I think this should be sms_to to be consistent with email_to

@aantix
Copy link
Contributor Author

@aantix aantix commented Jun 18, 2019

I think this should be sms_to to be consistent with email_to

Fair point. Changed the method name to sms_to.

@rafaelfranca rafaelfranca requested a review from guilleiguaran Jun 18, 2019
…/desktop's messaging client with the phone number and optional body value prepopulated.
@aantix aantix force-pushed the sms_link_helper branch from 388c598 to 3115b73 Jun 18, 2019
Copy link
Contributor

@sharang-d sharang-d left a comment

Simple doc changes :)

actionview/lib/action_view/helpers/url_helper.rb Outdated Show resolved Hide resolved
actionview/lib/action_view/helpers/url_helper.rb Outdated Show resolved Hide resolved
actionview/lib/action_view/helpers/url_helper.rb Outdated Show resolved Hide resolved
actionview/lib/action_view/helpers/url_helper.rb Outdated Show resolved Hide resolved
@aantix
Copy link
Contributor Author

@aantix aantix commented Jul 19, 2019

Are there any additional messaging clients that we can test this with?
https://sms-to-rails-test.herokuapp.com/

@guilleiguaran guilleiguaran merged commit ea91f9b into rails:master Jul 19, 2019
2 checks passed
@pdobb
Copy link

@pdobb pdobb commented Jul 21, 2019

🤜🏻🤛🏻

@bogdan
Copy link
Contributor

@bogdan bogdan commented Jul 22, 2019

body escaping had some problems in historical versions of iOS and Android.
We still have this workaround in our code:

    unless ios_greater_or_equal?("10", user_agent) ||   android_greater_or_equal?('6.0.1', user_agent) # problem was fixed in ios 10 and android 6.0.1+
      body.gsub!('%', '%25')
    end

Maybe this is still actual and should be supported.

https://stackoverflow.com/q/18120062/91610

# HTML attributes for the link can be passed in +html_options+.
#
# When clicked, an SMS message is prepopulated with the passed phone number
# and optional +body+ value.

image

Watch out for indentation here (being parsed as a code block)

Copy link
Member

@kamipo kamipo Jul 24, 2019

Good catch. Fixed by 0e149ab.

@aantix aantix deleted the sms_link_helper branch Jan 23, 2020
@Nodalailama
Copy link

@Nodalailama Nodalailama commented Jul 21, 2020

Hello,

There is a small problem: when I want to open sms app without any number, the ";" just before the "?" => "sms:;?" add in the phone field a blank phone number.

If you can remove the ";" when phone is blank then it work correctly.

Cordialement,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

8 participants