Dapp API Examples

Use imToken2.0 DApp browser scan this qrCode to view exmaples.
show code
imToken.callAPI('navigator.closeDapp')
      
show code
imToken.callAPI('navigator.goBack')
      
show code
imToken.callAPI('navigator.toggleNavbar')
      
show code
imToken.callAPI('navigator.getOrientation', function(err, result) {
	alert(result)
})
      
show code
imToken.callAPI('navigator.setOrientation', 'landscape')
      
show code
imToken.callAPI('navigator.setOrientation', 'portrait')
      
show code
      imToken.callAPI('navigator.configure', {orientation: 'portrait', navigationStyle: 'default'})
            
show code
        imToken.callAPI('navigator.configure', {orientation: 'portrait', navigationStyle: 'default', navigatorColor: '#008cd5'})
              
show code
    imToken.callAPI('navigator.configure', {orientation: 'portrait', navigationStyle: 'transparent'})
          
show code
    imToken.callAPI('navigator.configure', {orientation: 'landscape', navigationStyle: 'default'})
          
show code
      imToken.callAPI('navigator.configure', {orientation: 'landscape', navigationStyle: 'default', navigatorColor: '#008cd5'})
            
show code
  imToken.callAPI('navigator.configure', {orientation: 'landscape', navigationStyle: 'transparent'})
        
show code
imToken.callAPI('native.alert', 'winner winner, chicken dinner!')
      
show code
imToken.callAPI('native.selectPicture',{maxWidth: 400, maxHeight: 200}, function (err, ret) {
    if(err) {
      alert(err.message)
    } else {
      document.getElementById('imgContainer').src = ret.data
    }
  })
      
show code
 imToken.callAPI('native.setClipboard', 'are you ok?')
      
show code
imToken.callAPI('native.share', {
  title: 'dapp example',
  message: 'this is example of dapp sdk',
  url: location.href,
}, function (err, ret) {
  if(err) {
    alert('user not share')
  } else {
    alert('shared')
  }
})
      
show code
imToken.callAPI('native.scanQRCode', function (err, ret) {
  if(err) {
    alert(err)
  } else {
    alert(ret)
  }
})
      
show code
imToken.callAPI('user.showAccountSwitch', {
}, function(err, address) {
  if(err) {
    alert(err)
  } else {
    alert(address)
  }
})
      
show code
imToken.callAPI('device.getCurrentLanguage', function(err, language) {
  if(err) {
    alert(err)
  } else {
    alert(language)
  }
})
      
show code
imToken.callAPI('device.getCurrentCurrency', function(err, currency) {
  if(err) {
    alert(err)
  } else {
    alert(currency)
  }
})