Closed Huang-Liangjin closed 8 years ago
The only way for that to happen is if the subscription object is deallocated. Can you double check that unsubscribe() isn't being called?
Another way the subscription could be deallocated is if its owner (the NearbyMessage object) is deallocated, but since it's a singleton, that's probably not happening.
Thanks very much for replying. I'm sure that I didn't call the unsubscribe() method. The same thing also happens when I call the publish(). (It is unpublished immediately after publish() is called.) Still thank you for the hint, I'll check out whether the objc singleton object get wrong or not. And I'm sorry I made an issue which would probably has nothing wrong with Nearby API itself, is it better to close it?
One more idea: Do you have ARC enabled for your code? If not, the publication or subscription object would be immediately deallocated.
Don't close the issue yet. I'm curious to find out what's causing the problem; I'm always looking for ways to improve the developer experience.
Thank you so much!!!!!!! After adding the -fobjc-arc flag to mm files, it works!!!!!!!!
Great! Glad to help.
Since you are looking for ways to improve the developer experience, I get some other suggestions would be helpful to you. After comparing the Android API and iOS API, I noticed that iOS can not set the TTL of messages, it would be nice if the TTL is configurable for iOS. :smile:
may I close this issue now~? :smile:
Thanks for the feedback!
The reasons we don't support TTL on iOS is that (a) your app will almost certainly need to update the UI when the TTL expires, so you'll need to set a timer in your app, and (b) it's dead simple to set a timer on iOS using GCD.
Here's an example that nils out your subscription after 5 minutes:
dispatch_after( dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * 60 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self unsubscribe]; });
Thank you for your help sincerely~ :smile:
I want to use nearby api in a cocos2dx based project (c++ only), so I made a simple wrapper for nearby API, here it is: https://github.com/Huang-Liangjin/NearbyForCPP When I call the methods below:
the log output is
It is Unubscribed immediately after subscription.
could you help me to figure out why this happened, please?