Giter VIP home page Giter VIP logo

rn-ios-user-agent's Introduction

Android advertising using beacons

Installation

To integrate Tagipedia into your Android project, add it to your gradle:

repositories {
    maven { url "https://github.com/tagipedia/tagipedia/raw/master/" }
}

dependencies {
    compile ('com.tagipedia:tagipedia:2.2.5@aar'){
        transitive = true;
    }
}

Usage

public class MyAppContext extends MultiDexApplication {
    public void onCreate() {
        super.onCreate();
        TBuilder tBuilder = new TBuilder(this, "CLIENT_ID", "CLIENT_SECRET", "IDENTIFIER", "UUID");
        // intent that opened when notification pressed
        Intent intent = new Intent(getApplicationContext(), NotificationActivity.class);
        tBuilder.setIntent(intent);
        // set notification icon
        tBuilder.setSmallIcon(R.drawable.ic_launcher);
        // change notify period between different beacons notification in millisecond
        // DEFAULT: 10 * 60 * 1000 (10 minutes)
        tBuilder.setDifferentBeaconNotifyPeriod(1000);
        // change notify period between same beacons notification in millisecond
        // DEFAULT: 30 * 60 * 1000 (30 minutes)
        tBuilder.setSameBeaconNotifyPeriod(20000);
        Callback.OnLoggedEventRecordListener loggedEventRecordListener = new Callback.OnLoggedEventRecordListener() {
            @Override
            public void onEventLoggedRecord(HashMap hashMap) {
                System.out.print(hashMap);
            }
        };
        tBuilder.setEventLoggerListener(loggedEventRecordListener);
        // to receive feature_id if the action of ad is navigate to map location
        // you should open the map and navigate to the location that recived
        Callback.OnMapButtonPressedListener onMapButtonPressedListener = new Callback.OnMapButtonPressedListener() {
            @Override
            public void onMapButtonPressed(HashMap hashMap) {
                System.out.print(hashMap);
                // dispatch to tagipedia maps to navigate to location should be like this
                // LinkedHashMap<String, Object> navigationParams = new LinkedHashMap<String, Object>();
                // navigationParams.put("route_to", (String)hashMap("feature_id"));
                // new HashMap<String, Object>(){{
                // put("type", "SHOW_NAVIGATION_DIALOG");
                // put("navigation_params", navigationParams);
                // }}
            }
        };
        tBuilder.setMapButtonPressedListener(onMapButtonPressedListener);
        
        //to receive when user enter beacon region
        Callback.OnEnterBeaconRegionListener onEnterBeaconRegion = new Callback.OnEnterBeaconRegionListener(){
            @Override
            public void onEnterBeaconRegion(HashMap data) {
                System.out.print(data);
                //enter_date the date that the user enter the area which beacon cover it return in millisecond since 1970
                //data contain enter_date and others data belong to beacon
            }
        };
        tBuilder.setEnterBeaconRegionListener(onEnterBeaconRegion);
        //to receive when user exit beacon region
        Callback.OnExitBeaconRegionListener onExitBeaconRegion = new Callback.OnExitBeaconRegionListener(){
            @Override
            public void onExitBeaconRegion(HashMap data) {
                System.out.print(data);
                //time_spent the time that the user spent in the area which beacon cover it return in milliseconds
                //enter_date and exit_date the date that the user enter and exit the area which beacon cover it return in millisecond since 1970
                //data contain enter_date, exit_date, time_spent and others data belong to beacon
            }
        };
        tBuilder.setExitBeaconRegionListener(onExitBeaconRegion);
        
        //to monitoring specific regions
        tBuilder.setRegions(new ArrayList<TRegion>(Arrays.asList(new TRegion(UUID, major, minor), ...)));
        tBuilder.build();
        //to register user with interests
        //this will show ads based on matching between ad interests and user interests otherwise it will show ads that was created without interests
        //String[] interests
        TBuilder.identifyUser("USER_NAME", interests);
    }
}
public class NotificationActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_notification);
        Bundle bundle = getIntent().getExtras();
        HashMap topic = (HashMap) bundle.getSerializable("topic");
        System.out.println("Topic " + topic);
        // you can show ad with its assigned template
        TUtils.showAdDialog(this,topic);
        // you can use topic getters to display it in view
    }

}

Hint: to ask user to enable bluetooth we have method for it.

TUtils.showBluetoothDialog(this, "Open bluetooth" , "we use bluetooth for .... please open it");

Hint: to ask user to enable location for android bigger than or equal 23 we have method for it.

TUtils.showLocationDialog(this, "Open Location" , "we use location for .... please open it");

Hint: to show ad with its assigned template.

TUtils.showAdDialog(this,topic);

Hint: to logout user..

TBuilder.logoutUser();

Hint: to receive current region user located at. you should set the regions (ArrayList of TRegion ) before build

tBuilder.setRegions(new ArrayList<TRegion>(Arrays.asList(new TRegion(UUID, major, minor), ...)));

Sample code

https://github.com/tagipedia/tagipedia-android-sample

rn-ios-user-agent's People

Contributors

mehcode avatar shimaa-hassan avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.