search

Open gallery and pick an image JS API

Use Case

Use the bridge below to open a custom image picker, and get a callback once the user has picked an image or has canceled.

 

Note:

  • In iOS, no implementation is needed and web methods to invoke/use Gallery will work.
  • In Android, merchant must call paytmCheckPermission JS API & paytmRequestPermission JS API to check if storage permission is granted or not before calling paytmOpenGallery.

Request Attributes

API Content format: JSON

ATTRIBUTES DESCRIPTION

requestCode

mandatory

Android recognizes it, safe to pass for both iOS and Android
Example: 456

title

optional

Title to be displayed on activity picker dialog (only Android recognizes it, safe to pass for both iOS and Android)

Example: Paytm

Response Attributes

Success

Note: Response comes in JSON with 'data' as key.

 

ATTRIBUTES DESCRIPTION
data.base64 The base 64 string of the image received

Example: 1

data.meta.imageName

ImageName

Example: 100002890.jpg

data.meta.imageSize

Image size in bytes

Example: 1941277

data.meta.imageType

This includes image type (jpg, png, etc)

Example: "jpg"

 

ERROR CODES

PARAMETER DESCRIPTION
error Error
Example: 2
message Error Message
Example: Invalid parameter

ERROR RESPONSES

CODE DESCRIPTION
2 Invalid parameter
REQUEST
RESPONSE
JAVASCRIPT
const requestObject = {
    requestCode: 456, //only Android recognizes it, safe to pass for both iOS and Android title: 'Title to be displayed on activity picker dialog'//only Android recognizes   it, safe to pass for both iOS and Android} JSBridge call{'paytmOpenGallery', requestObject, function(result) {console.log(JSON.stringify(result))});
copy icon