cubeacon / android-cubeacon-sample

Android Cubeacon Sample Project
12 stars 10 forks source link

background notification #3

Closed andra17 closed 9 years ago

andra17 commented 9 years ago

i tried to make the same app with the code from the video of demoapp but, my background notification like entering beacon and exitting beacon can't show up ,how can i fix it?

best regard,

andra17 commented 9 years ago

and if i want to create my custom activty of the beacon ,e.g when entering beacon the app showing a table, where i should put the code in the eclipse project?

best regard

alann-maulana commented 9 years ago

Hi @andra17,

I hope you already read about how to setup Cubeacon SDK Installation. If yes, there is some step you need to check :

  1. Check on Cubeacon Developer Portal -> Beacons Menu, that your beacon parameters like UUID, major and minor value are correct.
  2. Check your storyline on Storyline Menu, that you have a story with event onEnter and onExit. Don't forget to enable the storyline by switching to ON.
  3. If you want to automatically show the default storyline campaign, you can enable the schedule days on the storyline menu. Otherwise, disable all campaign days will disable the default storyline campaign. But, you can still use the callback function when beacon entered and exited :
        @Override
        protected void onBeaconExited(CBBeacon beacon, long timeInterval) {
            // do something when beacon exited region
        }

        @Override
        protected void onBeaconEntered(CBBeacon beacon) {
            // do something when beacon entered region
        }

Best Regards.

andra17 commented 9 years ago

so if i want to make my own custom campaign i have to put my code on protected void onBeaconExited(....){

} cmiiw

best regards,

andra17 commented 9 years ago

okey, if i disable the campaign's day, can i still receive the background notification? or i have to code it by myself?

best regards,

alann-maulana commented 9 years ago

Hi @andra17,

If you want disable the campaign's day, it will just disable the existing storyline campaign provided by Cubeacon SDK. But you can still received the background callback function like onBeaconEntered and onBeaconExited. Some example code, showing a notification when entering beacon's region :

@Override
protected void onBeaconEntered(CBBeacon beacon) {
    // showing notification when entering region of a beacon
    NotificationCompat.Builder mBuilder =   new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_launcher) // notification icon
            .setContentTitle("Cubeacon background notification") // title for notification
            .setContentText("You have entering region of a beacon...") // message for notification
            .setAutoCancel(true); // clear notification after click
    Intent intent = new Intent(this, BeaconActivity.class);
    PendingIntent pi = PendingIntent.getActivity(this,0,intent,Intent.FLAG_ACTIVITY_NEW_TASK);
    mBuilder.setContentIntent(pi);
    NotificationManager mNotificationManager =
                    (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(0, mBuilder.build());
}

Best Regards.

andra17 commented 9 years ago

okey thank you very much ,work perfectly

Best Regard,

alann-maulana commented 9 years ago

OK @andra17, we will close this issue. Please open a new issue if you have another question. Thanks.

Best Regards.