Free Mobile for Dart

Release License Build

Send SMS messages to your Free Mobile account, in Dart.

To use this library, you must have enabled SMS Notifications in the Options of your Subscriber Area.

Requirements

The latest Dart SDK and Pub versions. If you plan to play with the sources, you will also need the latest Grinder version.

Installing via Pub

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  free_mobile: *

2. Install it

Install this package and its dependencies from a command prompt:

$ pub get

3. Import it

Now in your Dart code, you can use:

import 'package:free_mobile/free_mobile.dart';

Usage

This package provides a single class, Client, which allow to send messages to your mobile phone by using the sendMessage() method:

try {
  var client = new Client('your user name', 'your identification key');
  await client.sendMessage('Hello World!');
  print('The message was sent successfully.');
}

catch (error) {
  print('An error occurred: $error');
}

The text of the messages will be automatically truncated to 160 characters: you can't send multipart messages using this library.

Events

The Client class triggers some events during its life cycle:

  • request : emitted every time a request is made to the remote service.
  • response : emitted every time a response is received from the remote service.

These events are exposed as Stream, you can listen to them using the on<EventName> properties:

client.onRequest.listen(
  (request) => print('Client request: ${request.url}')
);

client.onResponse.listen(
  (response) => print('Server response: ${response.statusCode}')
);

Unit tests

In order to run the tests, you must set two environment variables:

$ export FREEMOBILE_USERNAME="<your Free Mobile user name>"
$ export FREEMOBILE_PASSWORD="<your Free Mobile identification key>"

Then, you can run the test script from the command prompt:

$ pub run test

See also

License

Free Mobile for Dart is distributed under the Apache License, version 2.0.

Libraries

free_mobile

Send SMS messages to your Free Mobile account.