I have the following problem: my code uses ConnectApi.ChatterFeeds.postFeedElement and ConnectApi.ChatterFeeds.postFeedElementBatch methods to operate feed items. That works properly is Chatter is enabled for the org, but ... if it's disabled I can't even install my package because of Invalid class ChatterFeeds exception coming from my unit tests. I realize that some Chatter object aren't accessible when Chatter is disabled (for example FeedItem), but you can always write
SObjectType token = Schema.getGlobalDescribe().get('FeedItem'); SObject objPost = token.newSObject();
FeedItem f = new FeedItem();
Does anyone know if there is a workaround like that for ChatterFeeds class methods? Or I have to get rid of ConnectApi and rewrite my Chatter logic somehow else?
UPDATE (Sep 29 2015)
Salesforce team just confirmed it is a known behavior: ConnectApi expects Chatter to be enabled and that's a runtime check which can't be avoided.
UPDATE (Nov 10 2015)
Fixed by Salesforce in Winter'16 Patch 11.0 (already deployed to the most org). Details are here