This project creates javascript code that will be injected into Portkey APP's WebView environment, for providing basic functions for DApp developers.
We recommend to use the @portkey/detect-provider package to detect if Portkey is injected.
Click the link above to learn more.
provider will be injected to the window
or globalThis.window
object, providing you a way to detect it directly.
Also, when provider is injected, an event named portkeyInitEvent
will be triggered on the host object (window
).
const detectedProvider:IProvider = 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.