Estimote Proximity

Hi!

I’m having a problem with estimotes proximity. I have downloaded the package example for my projeto (after create a new app thrown the estimote Cloud) and put in my phone to check if it work or not.

What i check is that the range, by default, is set to 3.0, but when i put the app on my phone, a received both of Hello notification and Goodbye notification. The GoodBye notification must open only after a get out of this range (3). What is wrong?

I didnt change anything, a just download the app and create the .apk to verify the funcionality.

Codes:

class MyApplication : Application() {

    val cloudCredentials = EstimoteCloudCredentials("proximitypush-cwj", "KEY_OF_APP")

    fun enableBeaconNotifications() {
        val notificationsManager = NotificationsManager(this)
        notificationsManager.startMonitoring()
    }

}

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val app = application as MyApplication

        RequirementsWizardFactory
                .createEstimoteRequirementsWizard()
                .fulfillRequirements(this,
                        onRequirementsFulfilled = {
                            Log.d("app", "requirements fulfilled")
                            app.enableBeaconNotifications()
                        },
                        onRequirementsMissing = { requirements ->
                            Log.e("app", "requirements missing: " + requirements)
                        },

                        onError = { throwable ->
                            Log.e("app", "requirements error: " + throwable)
                        })
    }

}


class NotificationsManager(private val context: Context) {

    private val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
    private val helloNotification = buildNotification("Hello", "You're near your beacon")
    private val goodbyeNotification = buildNotification("Bye bye", "You've left the proximity of your beacon")

    private fun buildNotification(title: String, text: String): Notification {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            notificationManager.createNotificationChannel(NotificationChannel(
                    "content_channel", "Things near you", NotificationManager.IMPORTANCE_HIGH))
        }

        return NotificationCompat.Builder(context, "content_channel")
                .setSmallIcon(android.R.drawable.ic_dialog_info)
                .setContentTitle(title)
                .setContentText(text)
                .setContentIntent(PendingIntent.getActivity(context, 0,
                        Intent(context, MainActivity::class.java), PendingIntent.FLAG_UPDATE_CURRENT))
                .setPriority(NotificationCompat.PRIORITY_HIGH)
                .build()
    }

    fun startMonitoring() {
        val notificationId = 1
        val proximityObserver = ProximityObserverBuilder(context, (context as MyApplication).cloudCredentials)
                .onError { throwable ->
                    Log.e("app", "proximity observer error: $throwable")
                }
                .withBalancedPowerMode()
                .build()

        val zone = ProximityZoneBuilder()
                .forTag("proximitypush-cwj")
                .inCustomRange(2.0)
                .onEnter {
                    notificationManager.notify(notificationId, helloNotification)
                }
                .onExit {
                    notificationManager.notify(notificationId, goodbyeNotification)
                }
                .build()
        proximityObserver.startObserving(zone)

    }

}

Someone can help me with this issue?

Hello @dzabeu
We need some more information:

  • What is the Proximity-sdk version you are using?
  • What is the Android version you are launching your application on?
  • What is phone model you are using?
  • What is the distance between phone and beacon when you are observing the issue?

Regards
Wojtek

Hi Woj,

I`m using a Motorola G3 and a Xiaomi A1 , both have the same problem. I put the beacon near from the smarthphone

Following the code with versions and other configuration:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.estimote.notification"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

    implementation 'com.estimote:proximity-sdk:1.0.3'
    implementation 'com.estimote:mustard:0.2.1'
}