laravel-notification-channels / twilio

Twilio notifications channel for Laravel
https://laravel-notification-channels.com
227 stars 36 forks source link

Added alphanumeric sending, and messaging service capabilities, support for Twilio SDK 5 #15

Closed lnpbk closed 7 years ago

lnpbk commented 8 years ago

I have added 2 new features:

Messaging Service

The ability to use a Twilio Messaging Service. Just add sms_service_sid to your Twilio services config, like so:

'twilio' => [
    'account_sid'     => env('TWILIO_SID'),
    'auth_token'      => env('TWILIO_TOKEN'),
    'from'            => env('TWILIO_NUMBER'),
    'sms_service_sid' => env('TWILIO_SERVICE_SID'),
]

Alphanumeric Senders

To implement alphanumeric senders, add your sender name to your Twilio services config, like so:

'twilio' => [
    'account_sid'     => env('TWILIO_SID'),
    'auth_token'      => env('TWILIO_TOKEN'),
    'from'            => env('TWILIO_NUMBER'),
    'sms_service_sid' => env('TWILIO_SERVICE_SID'),
    'alphanumeric_sender' => 'Sender Name'
]

Alphanumeric senders are available on a county-by-country basis (https://support.twilio.com/hc/en-us/articles/223133767-International-support-for-Alphanumeric-Sender-ID), so you need to implement the following method on your $notifiable class:

public function canReceiveAlphanumericSender()
{
    return true;
}

Use this method to determine whether the Model can receive Alphanumeric senders or not

Footnote

I noticed @casperboone's pull request, which looks great, and once pulled in, I'd be happy to contribute these changes to the new format.

gregoriohc commented 8 years ago

Great! I'm just waiting for @casperboone confirmation to merge his pull request.

gregoriohc commented 8 years ago

@leon13, I'm still waiting for @casperboone to commit more changes to his PR ;)

lnpbk commented 8 years ago

No problem

gregoriohc commented 8 years ago

Sorry for the delay @leon13. I have been busy the past two week. I have now merged the @casperboone pull request. Can you refactor your changes over the new master branch? Thanks!

lnpbk commented 8 years ago

I'm currently working on this, and hope to have it done within the next couple of days

lnpbk commented 8 years ago

If anyone has the ability to test the calling ability with this code, that'd be great. I only have SMS capable numbers at the moment.

lnpbk commented 8 years ago

This is ready for review @gregoriohc

mickeyschwab commented 7 years ago

Is there any traction on this? Would love to see the Twilio 5+ sdk implemented while we transition over from inhouse notifications to the Laravel 5.3 package but can't install 4 & 5 simultaneously.

lnpbk commented 7 years ago

@mickeyschwab Unfortunately I haven't heard anything. Feel free to try my fork

gregoriohc commented 7 years ago

Sorry guys. I have been very busy the last few months and I haven't tested this yet. I will try to do it this week. @lnpbk, this PR has breaking changes with the current version, isn't it? Maybe the best thing we can do is to merge it and release a new 2.0 version?

lnpbk commented 7 years ago

No probs @gregoriohc. I don't believe there are any breaking changes, but maybe it'd be wise to tag a new version, as my PR bumps the Twilio Sdk version requirement up to version 5.

tonnyorg commented 7 years ago

@lnpbk @gregoriohc do you need help here? I would like to have this released as the current version doesn't work anymore (I'm getting ""Could not resolve host: "" as exception message) and as far as I can trace it's because SDK 4.x so I would like to upgrade.

Let me know if I can help you (coding) so we can get this official release soon.

lnpbk commented 7 years ago

@TonnyORG Thanks for the offer, and any review of the PR is greatly appreciated!

DMeganoski commented 7 years ago

Having the same issue as @TonnyORG

It seems they may have discontinued the version 4 api, finally.

Using @lnpbk version and seems to work fine for sms, I am also only on a trial account so can't test the calling functionality.

gregoriohc commented 7 years ago

Sorry for the delay. This has been tested, merged and released as 2.0.0 version.