[Sessions] Small fix on HTTP queue to avoid losing events

When app is resumed, we're now restoring queue from cached plist
before anything else, to avoid losing events.

Signed-off-by: Miguel M. Almeida <miguelcma@gmail.com>
[Sessions] _endSession .timestamp equals to .ended_at

Session's `session.ended_at` value already had the correct time (when
the app gone to background). However, datapoint's `timestamp` and
`event.date` will have a date in the future, which is the date when
the data point is tracked. To avoid this, we're setting all the three
dates with the same value.

Signed-off-by: Miguel M. Almeida <miguelcma@gmail.com>
[Sessions] _startSession .timestamp equals to .started_at

Signed-off-by: Miguel M. Almeida <miguelcma@gmail.com>
[User] Auto Identify using user from last launch

Instead of auto identifying user with an anonymous user,
we now use the last used User (from last launch).

Signed-off-by: Miguel M. Almeida <miguelcma@gmail.com>
[Tests] workaround for Kiwi tests "glitches"

Workaround for a Kiwi bug that causes random `malloc` errors

Signed-off-by: Miguel M. Almeida <miguelcma@gmail.com>
[Reidentify] Add methods to allow reidentify of users

With this method, it is now possible to ask Liquid server to reidentify
auto identified users with the `user.unique_id` of further users.

Signed-off-by: Miguel M. Almeida <miguelcma@gmail.com>
[User] Deprecate identifyUser methods

Deprecated:

* `-(void)identifyUser`
* `-(void)identifyUserWithAttributes:(NSDictionary *)attributes`

Added new methods:

* `[Liquid resetUser]`

Signed-off-by: Miguel M. Almeida <miguelcma@gmail.com>
[User] Generate a new User ID on auto identify

Instead of using always the device UID as user ID, from now on
when a user is auto identified, a new UUID is generated.

Signed-off-by: Miguel M. Almeida <miguelcma@gmail.com>
[Demo] changed to reflect auto identified users

Signed-off-by: Miguel M. Almeida <miguelcma@gmail.com>
Use md5 on cache name files to avoid invalid caracters

API Tokens could eventually contain invalid characters for the file system. So,
to avoid this problem, API token is hashed (md5) for the file names.

Cache files locations:

* HTTP Requests Queue: `/path/to/md5(api_token).queue`
* Liquid Package: `/path/to/md5(api_token).last_liquid_package`
* Last User: `/path/to/md5(api_token).last_user`

Signed-off-by: Miguel M. Almeida <miguelcma@gmail.com>
[Fix] an eventual memory leak on iOS 5

Signed-off-by: Miguel M. Almeida <miguelcma@gmail.com>
[Fix] an eventual memory leak when loading a Liquid Package

Signed-off-by: Miguel M. Almeida <miguelcma@gmail.com>
[Users] is now stored on a different file per API Token

Signed-off-by: Miguel M. Almeida <miguelcma@gmail.com>
[Log] Add missing log on message when a L.Package is loaded

Signed-off-by: Miguel M. Almeida <miguelcma@gmail.com>
[Fix] a bad access that could occur when saving a L.Pacakge

Signed-off-by: Miguel M. Almeida <miguelcma@gmail.com>
[Code Review] change a value from 1 to 1.0f

Signed-off-by: Miguel M. Almeida <miguelcma@gmail.com>
[Users] User alias is now the default behaviour

Signed-off-by: Miguel M. Almeida <miguelcma@gmail.com>