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:

  1. In iOS no implementation is needed and web methods to invoke / use Gallery will work.
  2. 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

ATTRIBUTEDESCRIPTIONREQUIREDEXAMPLE VALUE
requestCodeAndroid recognizes it, safe to pass for both iOS and AndroidYes456
titleTitle to be displayed on activity picker dialog(only Android recognizes it, safe to pass for both iOS and Android)NoPaytm

Response Attributes

Success:

Note: Response comes in json with 'data' as key

PARAMETERDESCRIPTIONEXAMPLE VALUE
data.base64The base 64 string of the image received1
data.meta.imageNameImageName100002890.jpg
data.meta.imageSizeImage size in bytes1941277
data.meta.imageTypeThis includes image type (jpg, png, etc)"jpg"

Error Responses:

PARAMETERDESCRIPTIONEXAMPLE VALUE
errorError2
messageError messageinvalid parameters

Error Codes

CODEDESCRIPTION
2Invalid parameter
REQUEST CODE
RESPONSE CODE
JAVASCRIPT
copy content icon

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',requestObje
  ct,
    function(result) {
       console.log(JSON.stringify(result))
  });