2

I am using chatter group and implemented the Push Notification using ConnectApi.ChatterFeeds.postFeedElementBatch(Network.getNetworkId(), chatterPosts), but the push notification is not working. Now if i try for single user or loop over the group it work and the notification is getting posted in mobile devices but as soon as i try it for a group the notification feature stops working.

ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput(); 
ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput(); 
messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>(); 
for(CollaborationGroup cgG : chGroup)
    { ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
      mentionSegmentInput.id = cgG.Id; 
      messageBodyInput.messageSegments.add(mentionSegmentInput);
    } 
 ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput(); 
 textSegmentInput.text = 'please check'; messageBodyInput.messageSegments.add(textSegmentInput); 
 feedItemInput.body = messageBodyInput; 
 feedItemInput.feedElementType = ConnectApi.FeedElementType.FeedItem; 
 feedItemInput.subjectId = newVisit.id; 
 ConnectApi.BatchInput batchInput = new ConnectApi.BatchInput(feedItemInput); 
 chatterPosts.add(batchInput); 
 ConnectApi.ChatterFeeds.postFeedElementBatch(Network.getNetworkId(), chatterPosts); 

Note : I made all necessary changes in salesforce1 Setting to enable the Push notification.

  • Can you share your code snippet specifically how you are accessing the group and linking the postFeedElementBatch to the group? – Gaurav Kheterpal Jan 7 '16 at 7:05
  • The Code is given below: – Saikat Sarkar Jan 8 '16 at 8:00
  • Where did you add it? I don't see anything – Gaurav Kheterpal Jan 8 '16 at 8:01
  • ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput(); ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput(); messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>(); for(CollaborationGroup cgG : chGroup){ ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();mentionSegmentInput.id = cgG.Id; – Saikat Sarkar Jan 8 '16 at 8:05
  • messageBodyInput.messageSegments.add(mentionSegmentInput);} ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput(); textSegmentInput.text = 'please check'; messageBodyInput.messageSegments.add(textSegmentInput); feedItemInput.body = messageBodyInput; feedItemInput.feedElementType = ConnectApi.FeedElementType.FeedItem; feedItemInput.subjectId = newVisit.id; ConnectApi.BatchInput batchInput = new ConnectApi.BatchInput(feedItemInput); chatterPosts.add(batchInput); ConnectApi.ChatterFeeds.postFeedElementBatch(Network.getNetworkId(), chatterPosts); – Saikat Sarkar Jan 8 '16 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.