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

I think this should be sms_to to be consistent with email_to

@aantix
Copy link
Contributor Author

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.

…/desktop's messaging client with the phone number and optional body value prepopulated.
Copy link
Contributor

@sharang-d sharang-d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 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
@pdobb
Copy link

pdobb commented Jul 21, 2019

🤜🏻🤛🏻

@bogdan
Copy link
Contributor

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed by 0e149ab.

@aantix aantix deleted the sms_link_helper branch January 23, 2020 19:18
@Nodalailama
Copy link

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
Development

Successfully merging this pull request may close these issues.

8 participants