Event API overview

Follow

You can use events to notify the Beemray backend of any relevant action that happened in your app. This is an example of how to create an event and send it to the backend. Remember that Beemray service must be running:

BeemrayEvent *event = [[Beemray sharedInstance] createEventWithTitle:@"Amazing goal"];
[event addElement:[[BeemrayEventElementBoolean alloc] initWithTitle:@"penalty" value:YES]];
[event addElement:[[BeemrayEventElementNumber alloc] initWithTitle:@"playernumber" value:@9]];
[event addElement:[[BeemrayEventElementString alloc] initWithTitle:@"name" value:@"Leo Messi"]];
[event addElement:[[BeemrayEventElementTime alloc] initWithTitle:@"time_of_goal" value:600]];
[event addElement:[[BeemrayEventElementTimestamp alloc] initWithTitle:@"match_date" value:[NSDate date]]];
 
dispatch_async(dispatch_get_main_queue(), ^{
    NSError *error;
    BOOL success = [[Beemray sharedInstance] sendEvent:event withError:&error];
    if(!success)
        NSLog(@"Error sending event: %@", error);
});

NOTES:

- If you use createEventWithTitle: method instead of directly instantiating the event, it will contain the current stand (which is normally what you want).

- Method sendEvent: is blocking and must not be called from the UI thread. In this case, we call it from a background thread using dispatch_async.

Have more questions? Submit a request

Comments