BranchMetrics / capacitor-branch-deep-links

Capacitor plugin for branch.io deep links
MIT License
32 stars 44 forks source link

Add support for custom deeplink image #58

Open deficts opened 2 years ago

deficts commented 2 years ago

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.

jf-branch commented 2 years ago

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

deficts commented 2 years ago

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

jf-branch commented 2 years ago

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))
})
deficts commented 2 years ago

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

deficts commented 2 years ago

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

jf-branch commented 2 years ago

@deficts yes it will work for showShareSheet as well.

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

deficts commented 2 years ago

image

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

jf-branch commented 2 years ago

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

deficts commented 2 years ago

Thank you for the attention and support!!!

jf-branch commented 2 years ago

@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

deficts commented 2 years ago

@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!