Subscribing to events not working

I am using Particle for a product. I am noticing that subscribing to events in the iOS app I developed and released is no longer working. I am able to subscribe fine, but I never get any events. Webhooks work and the console does display the events. For more context, I am using a customer access token with the Particle SDK and am able to call functions on the device just fine. Subscribing via curl in the terminal with the access token succeeds but never prints out data, unless I publish an event via curl with the same access token. Has anyone had this issue?

How are you publishing the events? With what access token and public or private?

Note that product events are one-way. They only exist to send data from a product device to the cloud. The reverse is not true. You can’t publish a product event and have it go to all product devices.

The only way to send a PRIVATE event to a product device is to use the customer-scoped access token and publish the private event that way.

This explains it a bit more:

I am publishing private events from the device to the cloud only. No device subscribes to events. Only the iOS app subscribes to the events from a device the customer owns and can control via their customer access token.

For the test I ran via curl, I used:
curl -d “name=myevent” -d “data=Hello World” -d “private=true” -d “ttl=60” -d "access_token=customer_access_token_here"
to publish and I used:
curl ""
to subscribe.
I only got:
event: myevent
data: {“data”:“Hello World”,“ttl”:60,“published_at”:“2018-03-13T16:49:55.578Z”,“coreid”:“api”}
even though the console does show the events published by the device belonging to that customer.

OK, I think I understand. I set up a Photon using two-legged auth in a custom app using an injected customer-scoped access token. I set up the Photon with a standard iOS device flow, and since I used an injected access token I wasn’t prompted for a username/password.

The device appeared in the console in my product with the correct owner, the two-legged auth shadow customer.

The device firmware publishes events.

I was able to receive these events in the console in the device-specific event log and in the product event log.

I was also able to subscribe to the events using curl. I used the same auth token I injected into the iOS app for claiming.

Since you’re not getting the device events from curl, I suspect that your device isn’t actually associated with the customer-scoped access token. The events are showing up in the product event log because they’re product events. But since you’re subscribing with a customer-scoped access token, it’s not seeing those events because they’re not matched up for some reason.

Tested with system firmware 0.6.3.

Thanks for taking the time to set this up and look into it, I appreciate it :slight_smile:
The customer and access token are matched to the device. I can actually control the customer’s device by calling functions in the iOS app using the customer access token. And I can see the events published by the customer’s device as a result of those function calls. But those events never make it to the iOS app nor my terminal via curl.

Should clarify: I can see the events published by the customer’s device as a result of those function calls in the console only.

That’s mysterious. It definitely should work and it did in my test.

Just to be sure: You’re publishing from your device with the PRIVATE flag, correct? There are some weird corner cases when you mix public events and private event subscriptions.

1 Like

I discovered the issue.
I’ve always been using private events. To check, I clicked on one of the events in the console to open up the JSON. As expected, public was set to false. However, the userid field was “” (but the owner field was populated with the right email, and I could make function calls with the customer access token).
Up until now, I had been using a test customer access token linked to devices I have in the office. I used an actual customer access token with a device in the field, and userid was populated. I used the app with that access token and the events were going through.
The only difference between the two are that I claimed the devices in the office via the curl command, as opposed to using Particle’s soft ap claim process, since the devices in the office were already set up with WiFi and online.
Going back to the test customer access token, I claimed a device in the office via the soft ap process, and now the events go through. But I assume claiming through curl should not intentionally result in these differences?