Pub/Sub - Push to API when STATE is ACTIVE on Enrollment

Viewed 200

I have implemented to PUSH a PUB/SUB notification to my POST API with the device details on ENROLLMENT. But notification comes in while the device STATE is still PROVISIONING

Is there a way to get the notification only when the STATE is ACTIVE ? This would help us in getting IMEI of the device only after Enrollment is complete to add it into our DB.

  1. My Policy contains absolutely nothing, so Policy is compliant.
{
  "name": "enterprises/LC023XXXX/policies/Policy_D-a26fead-4c03-b987-b5692e23ab19",
  "version": "18"
}
  1. When I fetch Device Info, it's ACTIVE :
{
  "name": "enterprises/LC023XXX/devices/343ee9888eXXXXX",
  "managementMode": "PROFILE_OWNER",
  "state": "ACTIVE",
  "appliedState": "ACTIVE",
  "policyCompliant": true
}
  1. But with ENROLLMENT status, Pub/Sub never sends with State : ACTIVE :
{
 "name": "enterprises/LC021mqgu0/devices/34aeb69ab34355aa",
 "managementMode": "PROFILE_OWNER",
 "state": "PROVISIONING",
 "enrollmentTime": "2020-06-14T10:20:01.713Z",
 "lastPolicySyncTime": "2020-06-14T10:20:01.716Z"
}
  1. Here's how my Enterprise is configured :
{
  "name": "enterprises/LC02XXXXX",
  "enabledNotificationTypes": [
    "ENROLLMENT"
  ],
  "pubsubTopic": "projects/projectName/topics/enrollmentNotification"
}

I have tried with multiple Enterprises and none of the enterprises send me the expected STATE - ACTIVE

Any help on what's causing this?

1 Answers

The STATE - ACTIVE notification will only be sent via status report so you have to set enabledNotificationTypes to also include STATUS_REPORT. You will receive this notification once the enrollment is completed and the device syncs the assigned policy.

Your enterprise should be configured as follows:

{ 
  "name": "enterprises/LC02XXXXX", 
  "enabledNotificationTypes": [ "ENROLLMENT","STATUS_REPORT" ], 
  "pubsubTopic": "projects/projectName/topics/enrollmentNotification" 
}
Related