Skip to content

Instantly share code, notes, and snippets.

View pkramaric's full-sized avatar

Petar Kramaric pkramaric

  • Flybits
  • Toronto
View GitHub Profile
@pkramaric
pkramaric / SignedRequestSteps.txt
Created November 22, 2017 15:54
This Gist shows how to set up your X.509 public/private certificate on Flybits
Initial Setup
1. Create an X.509 certificate ( You can use tools like https://www.samltool.com/self_signed_certs.php to help you out)
2. Make sure you save "Private Key"/"X.509 cert"
3. Upload your X.509 certificate to your Flybits Project through the Signed Login Settings of the Communications tab within your Flybits project (https://devportal.flybits.com)
Login Process (Either device/server side)
1. Save User object to json file (ex. data.json)
Example
{
"email":"{{email@flybits.com}}",
@pkramaric
pkramaric / GetTags.java
Created May 9, 2017 16:22
Get the tags that have been created for this project
TagOptions options = new TagOptions.Builder()
.addSearch("keyword", TagOptions.SearchFields.NAME)
... //Additional Tag Options
.build();
Flybits.include(context).getTags(options, new IRequestPaginationCallback<ArrayList<Tag>>() {
@Override
public void onSuccess(ArrayList<Tag> data, Pagination pagination) {
}
@pkramaric
pkramaric / GetTags.java
Created May 9, 2017 16:22
Get the tags that have been created for this project
TagOptions options = new TagOptions.Builder()
.addSearch("keyword", TagOptions.SearchFields.NAME)
... //Additional Tag Options
.build();
Flybits.include(context).getTags(options, new IRequestPaginationCallback<ArrayList<Tag>>() {
@Override
public void onSuccess(ArrayList<Tag> data, Pagination pagination) {
}
@pkramaric
pkramaric / FlybitsOptionsApplication.java
Last active November 21, 2016 19:39
Demonstrates how to enable Context Uploading to the server through the FlybitsOptions object
FlybitsOptions options = new FlybitsOptions.Builder(MainActivity.this)
//Other possible Flybits Options
.enableContextUploading(1, ContextPriority.HIGH) //1 indicates the time in minutes to upload context
.build();
@pkramaric
pkramaric / BeaconContextPlugin.java
Created November 21, 2016 18:52
Snippet that demonstrates how the Beacon Context Plugin can be started from the application code.
FlybitsContextPlugin pluginBeacon = new FlybitsContextPlugin.Builder()
.setPluginIdentifier(AvailablePlugins.BEACON)
.setRefreshTime(60, 30, TimeUnit.SECONDS) //60 = refresh Time, 30 = flexible refresh rate
.build();
ContextManager.include(context).register(pluginBeacon);
@pkramaric
pkramaric / AndroidManifest.xml
Created November 21, 2016 18:50
The AndroidManifest.xml file for adding beacon support within your application.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="{yourPackageName}">
...
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- BEACON CONTEXT PERMISSION -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- BEACON CONTEXT PERMISSION -->
<permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- BEACON CONTEXT PERMISSION -->
<permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- BEACON CONTEXT PERMISSION -->
<uses-permission android:name="android.permission.BLUETOOTH"/> <!-- BEACON CONTEXT PERMISSION -->
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> <!-- BEACON CONTEXT PERMISSION -->
@pkramaric
pkramaric / subscribe_zone_push.m
Created October 11, 2016 15:13
Example of Subscribing to Zone based Push Notification from the Objective-C iOS Flybits SDK.
// 1. Subscribing to push notifications via a model object
Zone *myZone = <Zone received from an API request>
[myZone subscribeToPush];
// 2. Subscribing to push notifications via the PushManager
[[PushManager sharedManager] subscribeToTopic:@"zone/16667180-2BC0-4F8C-B31F-BD3C4FD6629E"];
@pkramaric
pkramaric / analytics_disconnection.m
Created September 30, 2016 13:20
An example of unregistering to zone or moment analytics (therefore closing the loop) with the Objective-C SDK
// Connect to a Zone ...
Zone *myZone = <Zone received from an API request>
DeviceQuery *query = [DeviceQuery queryForZone:myZone.identifier];
// ... or connect to a Moment
Moment *myMoment = <Moment received from an API request>
DeviceQuery *query = [DeviceQuery queryForMoment:myMoment.identifier];
[APIManager deviceDisconnect:query withCompletion:^(NSError * _Nullable error){
if (error) {
@pkramaric
pkramaric / analytics_disconnection.swift
Created September 30, 2016 13:18
An example of unregistering to zone or moment analytics (therefore closing the loop) with the Swift SDK
// Connect to a Zone ...
let myZone = <Zone received from an API request>
let query = DeviceQuery(.Zone, id: myZone.id)
// ... or connect to a Moment
let myMoment = <Moment received from an API request>
let query = DeviceQuery(.Moment, id: myMoment.id)
DeviceRequest.Disconnect(query) { (error) in
guard error == nil else {
@pkramaric
pkramaric / analytics_connection.m
Created September 30, 2016 13:17
An example of registering to zone or moment analytics with the Objective-C SDK
// Connect to a Zone ...
Zone *myZone = <Zone received from an API request>
DeviceQuery *query = [DeviceQuery queryForZone:myZone.identifier];
// ... or connect to a Moment
Moment *myMoment = <Moment received from an API request>
DeviceQuery *query = [DeviceQuery queryForMoment:myMoment.identifier];
[APIManager deviceConnect:query withCompletion:^(NSError * _Nullable error){
if (error) {