@portkey/mobile-provider
v2.3.5-alpha.5
Published
<p align="center"> <a href="https://portkeydocs.readthedocs.io/en/pre-release/PortkeyDIDSDK/index.html"> <img width="200" src= "https://raw.githubusercontent.com/Portkey-Wallet/portkey-web/master/logo.png"/> </a> </p> <h1 align="center">@portkey/m
Downloads
1,109
Maintainers
Keywords
Readme
This project creates javascript code that will be injected into Portkey Extension's WebView environment, for providing basic functions for DApp developers.
Usage
1. Use @portkey/detect-provider
We recommend to use the @portkey/detect-provider package to detect if Portkey is injected.
Click the link above to learn more.
2. Detect mobile-provider by your own code (not recommended)
mobile-provider will be injected to the window
or globalThis.window
object, providing you a way to detect it directly.
Also, when mobile-provider is injected, an event named portkeyInitEvent
will be triggered on the host object (window
).
const detectedProvider:MobileProvider = window.portkey;
if(!detectedProvider){
// Portkey is not injected yet
window.addEventListener('portkeyInitEvent', ()=>{
const provider = window.portkey;
// Do something with the provider
...
});
}
You can find more details and examples in @portkey/detect-provider 's README doc.