getsocial-im/getsocial-react-native-sdk

Can't post and load from group feed

Closed this issue · 1 comments

TypeError: undefined is not a function (near '...activityContent.attachments.add...')

const activityContent = new ActivityContent()
activityContent.text = "Hello, this is my second post!";
activityContent.attachments.add(MediaAttachment.withImageUrl('https://filedn.com/ltOdFv1aqz1YIFhf4gTY8D7/ingus-info/BLOGS/Photography-stocks3/stock-photography-slider.jpg'))

const target = PostActivityTarget.group(global.loggedInUser.group.id)
Communities.postActivity(activityContent, target)
    .then((result) => {
        console.log('Posted activity: ' + result)
    }, (error) => {
        console.log('Failed to post activity:  ' + error)
    })

hi,
you should add the attachment using push method:

activityContent.attachments.push(MediaAttachment.withImageUrl('https://filedn.com/ltOdFv1aqz1YIFhf4gTY8D7/ingus-info/BLOGS/Photography-stocks3/stock-photography-slider.jpg'));