- Does this package work with Laravel 8.x or 9.x? If not, what’s the workaround?
- This package is designed for Laravel 5.3/5.4 only. For newer Laravel versions, you’d need to fork the repository, update dependencies (e.g., `illuminate/notifications`), and test compatibility. Check the GitHub issues for potential community forks or consider alternatives like `notifications-channels/kavenegar`.
- How do I configure the Kavenegar API key and sender number?
- Add your API key and optional sender number to `.env` as `KAVENEGAR_API_KEY` and `KAVENEGAR_SENDER`. Then, define them in `config/services.php` under the `kavenegar` array. The package reads these values automatically during notification dispatch.
- Can I send SMS notifications to multiple recipients at once?
- No, this package sends SMS notifications one recipient at a time via the `routeNotificationForSms()` method. For bulk SMS, you’d need to loop through recipients manually or explore Kavenegar’s API directly for batch operations.
- How do I test SMS notifications in CI/CD without hitting rate limits?
- Mock Kavenegar’s API responses in your tests using Laravel’s HTTP client or a package like `mockery`. Override the `KavenegarChannel` to return a fake response instead of making real API calls. Example: Use `Http::fake()` in PHPUnit tests.
- What happens if the SMS fails to send? Are there retries or fallbacks?
- The package doesn’t include built-in retries or fallbacks. Failed SMS deliveries will trigger Laravel’s default notification failure handling. For retries, extend the `KavenegarChannel` class or use Laravel’s `NotificationFailed` event to implement custom logic, like email fallbacks.
- Is there a way to use SMS templates (e.g., predefined messages) with this package?
- No, this package only supports raw SMS text via the `toSMS()` method. For templates, you’d need to integrate Kavenegar’s API directly or extend the channel to support template IDs. Check Kavenegar’s [documentation](http://kavenegar.com) for template features.
- How do I log SMS delivery status (success/failure) for monitoring?
- Laravel’s notification system logs failures by default, but you’ll need to manually log successes. Extend `KavenegarChannel` to log responses using Laravel’s `Log` facade or a monitoring tool like Sentry. Example: `Log::info('SMS sent to ' . $phone, ['status' => $response->status])`.
- Does this package support sending SMS to international numbers?
- Yes, but Kavenegar’s sender number must be validated for international use. Ensure your sender number is configured to support global recipients. Test with a few numbers first, as regional restrictions may apply.
- What are the alternatives to this package for Laravel SMS notifications?
- Alternatives include `notifications-channels/kavenegar` (updated for newer Laravel), `spatie/laravel-sms-notifications` (supports multiple providers), or direct Kavenegar API integration. Choose based on Laravel version support and features like templates or scheduling.
- How do I handle rate limits or API throttling from Kavenegar?
- Kavenegar’s rate limits are documented [here](http://kavenegar.com). Implement exponential backoff in your `KavenegarChannel` by catching HTTP exceptions (e.g., `429 Too Many Requests`) and retrying with delays. Use Laravel’s `retry-after` logic or a queue worker for throttled requests.