Getting notified when the app is killed (just installed state) using Estimote monitoring 2.0 & Proximity beacons

Hi Team,

We need some help for the below explained scenario.

Assume that I am in a coffee shop and they have 3 proximity beacons. Of which 2 beacons are already assigned respective campaigns to be sent as notifications offers to the incoming customers. Now obviously, I have this coffee shop’s iOS app installed me being their regular customer. Currently, my app is just installed ( you can say killed state ). Now this Coffee shop owner adds new 3rd campaign to the third beacon ( other 2 campaigns are already running ). The struggling question is, if I have used Estimote monitoring 2.0 in my app, will this app get notified with the 3rd newly created campaign if in killed state ( already just installed in device )? . If yes, how can this be achieved?

We ready many blog post about monitoring and your answers to the developers. There are mixed views.

I will really appreciate if someone from the technical team can clarify the stand on the above scenario.

Many Thanks,

Kirtan Thaker

I’ll assume you’re using the iOS Proximity SDK (GitHub.com/Estimote/iOS-Proximity-SDK), and yes, this should work.

Say you all your 3 beacons have attachment “customer: coffee_shop”, and in your app, and you’re using that as your Proximity Zone in your app. Additionally, each beacon has an attachment campaign: one/two/three. And say you’re using this event handler:

zone.onChangeAction = { attachments in
    for attachment in attachments {
        let campaign = attachment.payload["campaign"]
        triggerCampaign(campaign)
    }
}

The next time the customer comes into the coffee shop, even if the first beacon they come in range of is the 3rd one, which the app previously didn’t know about, the app will get launched into the background. Then, fresh data will get pulled from Estimote Cloud, and all your action handlers will include the 3rd beacon and its attachment.

(The reason this works is, the Bluetooth filters we’re using aren’t for any specific beacons, but for any beacons with Estimote Monitoring enabled. So if you add a new beacon with Estimote Monitoring to the venue, even if the app doesn’t yet know about it, it’ll get launched into the background anyway.)

EDIT: Since you’re mentioning “just installed” a lot, note that the app has to be run at least once first, giving the Estimote Proximity SDK a chance to register itself with Core Bluetooth and Core Location! If the user installed the app but never run it, nothing will happen if they enter the coffee shop. This is true for any Bluetooth/Location apps.

Question 1)
Consider, I have two attachments. First for one meter distance, second for three meters and third for five meters. Is there any method available to tells the app which attachment has been executed out of three specified?

Question 2) In given scenario what if customer comes into the coffee shop and app didn’t aware with either beacons (1st or 3rd). Consider the customer is visiting shop very first time. And app is not running.

I am addressing this - “The next time the customer comes into the coffee shop, even if the first beacon they come in range of is the 3rd one, which the app previously didn’t know about, the app will get launched into the background.”

Question 3) Consider customer is in the coffee shop. They have placed their mobile on their table and already in the range of beacon 1. When they came in, there was no campaign scheduled for the beacon 1. Now, coffee shop owner creates a campaign for beacon 1. How the customer who is already in the coffee shop and in the range of beacon 1 get notified about it. Also consider there is no other beacon has been placed in that coffee shop.

Q1:

I feel there’s slight confusion here between an attachment and a proximity zone. (Good to know, we can try to disambiguate this better!)

In your case, you actually want 3 different proximity zones with the same attachment, not 3 different attachments:

let zone1 = EPXProximityZone(
  range: EPXProximityRange(desiredMeanTriggerDistance: 1.0)!,
  attachmentKey: "venue", attachmentValue: "coffee-shop-1")
zone1.onEnterAction = { _ in showCampaign("campaign-near") }

let zone2 = EPXProximityZone(
  range: EPXProximityRange(desiredMeanTriggerDistance: 3.0)!,
  attachmentKey: "venue", attachmentValue: "coffee-shop-1")
zone2.onEnterAction = { _ in showCampaign("campaign-mid") }

let zone3 = EPXProximityZone(
  range: EPXProximityRange(desiredMeanTriggerDistance: 5.0)!,
  attachmentKey: "venue", attachmentValue: "coffee-shop-1")
zone3.onEnterAction = { _ in showCampaign("campaign-far") }

Q2:

Right now, in this scenario (customer installs the app, and the app starts proximity-observing before the coffee shop owner sets up any beacons), you’ll get an error during startObserving:

Not all zones have devices assigned to them. Please double check spelling in zones naming and confirm with your Cloud account.

That is, it’s not possible to start observing for zone that at the time doesn’t have any matching beacons in Estimote Cloud.

However, this was already pointed out to us as problematic behavior, so we’re changing it. Proximity observation will start even if there are no matching beacons, and if you later add some in Estimote Cloud, they will generate enter events as expected.

In fact, this change is already implemented in the Android Proximity SDK, but not yet in the iOS Proximity SDK.

Q3:

This is actually up to you, but you can make it work. When the customer enters the coffee shop, the Proximity SDK will trigger an enter event for beacon 1. You send that information to your backend. The owner adds a campaign, the backend checks if there are any customers already inside the coffee shop that match the campaign’s criteria, and sends a push notification to them.

Thanks a lot for the help so far. I think we are closer. There is a little doubt again as explained below.

Lets say the coffee shop have 3 beacons with them. Currently no campaigns are running in their backend. They are about to use this app for the first time. Now I am (user with app installed and registered in it) in the shop, during this time the shop adds beacon 1 to their backend (the one we will provide ) and then creates a campaign for this added beacon, associates them with the beacon and start running it. How will my app start monitoring for the this newly added beacon? Will I get notified about this campaign if my app is in killed state?

I look forward to your reply.

If the beacon didn’t have the appropriate attachments when the user entered its range, the no, you generally won’t get an enter event if the attachment gets added while the user remains in range, because Proximity SDK only refreshes its list of matching beacon-attachments when startObserving is called.

You could however send a silent push notification to your app when a new beacon/campaign gets added to your backend, and re-start the proximity observer. When re-starting, it’ll fetch fresh data from Estimote Cloud, and since the beacon now has an attachment, it’ll immediately trigger an enter event.

Here’s a nice, short, high-level overview of how silent push notifications work:

Thanks Pior.

Now is there a way we can still achieve this without using Proximity SDKs and zones creating? With zones we would still have limitation of updating the app code again whenever a new zone is added.

Can we make use of Estimote monitoring2.0 ( ESTV2beaconmanager ) and still achieve this?

Many thanks,

Kirtan

Not sure I understand the problem—you can always create/manage the zones dynamically, e.g.:

let campaigns = fetchCampaigns()

var zones: [EPXProximityZone] = []
for campaign in campaigns {
  let zone = EPXProximityZone(
    range: EPXProximityRange(desiredMeanTriggerDistance: campaign.range)!,
    attachmentKey: "venue", attachmentValue: campaign.venue)
  zone.onEnterAction = { _ in showNotification(campaign.notificationText) }
  zones.append(zone)
}

proximityObserver.startObserving(zones)

This way, you can add campaigns in your own backend, and add beacons to a venue in Estimote Cloud, without changing the app’s code.

We don’t recommend using the ESTMonitoringV2Manager anymore—it won’t be receiving any new updates and improvements, outside maybe some critical bug fixes.

This above answer of yours is correct understanding. What we are asking is how do we make the above ‘multiple proximity zones with same attachment’ dynamic. In your previous answer you showed me how to create 3 zones as under. Can we generate them dynamically?

let zone1 = EPXProximityZone(
  range: EPXProximityRange(desiredMeanTriggerDistance: 1.0)!,
  attachmentKey: "venue", attachmentValue: "coffee-shop-1")
zone1.onEnterAction = { _ in showCampaign("campaign-near") }

let zone2 = EPXProximityZone(
  range: EPXProximityRange(desiredMeanTriggerDistance: 3.0)!,
  attachmentKey: "venue", attachmentValue: "coffee-shop-1")
zone2.onEnterAction = { _ in showCampaign("campaign-mid") }

let zone3 = EPXProximityZone(
  range: EPXProximityRange(desiredMeanTriggerDistance: 5.0)!,
  attachmentKey: "venue", attachmentValue: "coffee-shop-1")
zone3.onEnterAction = { _ in showCampaign("campaign-far") }

Waiting for your reply. Appreciate your assistance so far.

Thanks,

K

The code snippet I posted above should solve exactly that (:

If the fetchCampaigns function returns:

Campaign1:
  range: 1
  venue: "coffee-shop-1"
  notificationText: "campaign-near"

Campaign2:
  range: 3
  venue: "coffee-shop-1"
  notificationText: "campaign-mid"

Campaign3:
  range: 5
  venue: "coffee-shop-1"
  notificationText: "campaign-far"

… then the snippet will essentially create the 3 proximity zones from the earlier example.

Sure. much appreciated. will contact you again if the problem persists. Thank you.

Can u give example in react native for android device.suppose there are one beacons in one bus it should give notification about arriving at distance and time in my device.