capacitor-branch-deep-links icon indicating copy to clipboard operation
capacitor-branch-deep-links copied to clipboard

Add support for custom deeplink image

Open deficts opened this issue 3 years ago • 13 comments

I'm aware that is possible to add a custom url image in native plugins, I think it's an important feature for us capacitor users.

deficts avatar Apr 11 '22 19:04 deficts

Hi @deficts, could you provide additional detail as what you are referring too?

jf-branch avatar Apr 28 '22 15:04 jf-branch

So, in our app we implemented the deeplinking for sharing posts, that works well, but we want to be able to set a custom image in our deeplinks (right now when you share a deeplink the image shown, for example, in whatsapp is the icon of the app, but we want that image to be the image of the post). Tell me if im wrong but it is possible by customizing the contentImageUrl variable right? but in capacitor we are not able to access this variables, right? @jf-branch

deficts avatar Apr 28 '22 16:04 deficts

Thank you for the clarification @deficts. You can still do this through the capacitor SDK as well. When creating your properties, you can simply use the key as identified on the Universal Object , $og_image_url.

i.e

// optional fields
var analytics = {
  channel: 'facebook',
  feature: 'onboarding',
  campaign: 'content 123 launch',
  stage: 'new user',
  tags: ['one', 'two', 'three']
}

// optional fields
var properties = {
  $desktop_url: 'http://www.example.com/desktop',
  $android_url: 'http://www.example.com/android',
  $ios_url: 'http://www.example.com/ios',
  $ipad_url: 'http://www.example.com/ipad',
  $og_image_url: 'http://www.example.com/image.png',
  $match_duration: 2000,
  custom_string: 'data',
  custom_integer: Date.now(),
  custom_boolean: true
}

BranchDeepLinks.generateShortUrl({ analytics, properties }).then(function (res) {
  alert('Response: ' + JSON.stringify(res.url))
}).catch(function (err) {
  alert('Error: ' + JSON.stringify(err))
})

jf-branch avatar Apr 28 '22 17:04 jf-branch

Great! are these properties available using the showShareSheet method too? Thanks for the clarification!! @jf-branch

deficts avatar Apr 28 '22 17:04 deficts

Also, I think the $og_image_url property is not defined in this SDK see: https://github.com/BranchMetrics/capacitor-branch-deep-links/blob/master/src/definitions.ts#L27-L36

deficts avatar Apr 28 '22 18:04 deficts

@deficts yes it will work for showShareSheet as well.

I'm nearly certain it doesnt have to be defined in definitions.ts.

jf-branch avatar Apr 28 '22 18:04 jf-branch

image

I think the property must be included in definitions otherwise the project won't compile @jf-branch

deficts avatar Apr 28 '22 18:04 deficts

Got it! Thanks for testing! I'll create an internal ticket to get this updated.

jf-branch avatar Apr 28 '22 18:04 jf-branch

Thank you for the attention and support!!!

deficts avatar Apr 28 '22 18:04 deficts

@deficts I'm gonna talk to the engineer on this, but I'm thinking about just making BranchShortURLProperties a [String:String] object, because the API can accept any key value pair within the nested 'data' dictionary as long as its String:String. https://help.branch.io/developers-hub/docs/deep-linking-api#sample-request---create

jf-branch avatar Apr 28 '22 18:04 jf-branch

@deficts I'm gonna talk to the engineer on this, but I'm thinking about just making BranchShortURLProperties a [String:String] object, because the API can accept any key value pair within the nested 'data' dictionary as long as its String:String. https://help.branch.io/developers-hub/docs/deep-linking-api#sample-request---create

That sounds good, I'll keep an eye for any update, thanks again!

deficts avatar Apr 29 '22 14:04 deficts

Any updates on this?

nvahalik avatar Sep 17 '24 11:09 nvahalik

@jf-branch any update on this? I'm looking for this as well, but running into the same typescript issue.

ppatino avatar Oct 15 '24 16:10 ppatino