Particle.subscribe() warning when using in class

I have a class call CloudManager that is subscribing to cloud events. Following the docs, I have this:

class CloudManager {
    Particle.subscribe("hook-response/getSunrise", &CloudManager::getSunriseResponseHandler, this);
    Particle.subscribe("hook-response/getGoogleDocs", &CloudManager::getGoogleDocsResponseHandler, this);


  void getSunriseResponseHandler(const char *, const char *);
  void getGoogleDocsResponseHandler(const char *event, const char *data);

When I compile my code I get the following warning: (sorry for horizontal scroll)

 warning: 'bool CloudClass::subscribe(const char*, void (T::*)(const char*, const char*), T*) [with T = CloudManager]' is deprecated: Beginning with 0.8.0 release, Particle.subscribe() will require event scope to be specified explicitly. Define PARTICLE_USING_DEPRECATED_API macro to avoid this warning. [-Wdeprecated-declarations]
     Particle.subscribe("hook-response/getGoogleDocs", &CloudManager::getGoogleDocsResponseHandler, this);

I have tried replacing “this” with “MY_DEVICES” but that will not compile.

Does anyone know the “proper” way to construct a subscription method in a class?


Then it would be good to show what exactly the compile chokes up about this :wink:
Also how have you worded this?
Replacing this whith MY_DEVICES is definetly not the way. this is the pointer that references the “self” instance of the object and MY_DEVICES is no such pointer.

Try adding MY_DEVICES as extra parameter.

1 Like

Adding MY_DEVICES instead of replacing “this” with it was the way to go. Thanks!

Wondering if there’s additional documentation other than the docs for Particle.subscribe(). Is there a place to go that spells out all the ways it can be called?

You can browse the open source repo that shows how things are declared and implemented

1 Like

The embarrassing part for me is I actually looked in that exact file on github and wasn’t able to find that line and decipher an answer.

Thanks for tracking this down for me.

1 Like