Skip to main content
This guide provides integration examples for embedding the P2P.org Widget across different platforms and technologies. Each platform requires specific implementation approaches while maintaining the core functionality.

Swift (iOS)

Integrate the widget into iOS applications using WKWebView with proper wallet injection.

Implementation

  • Use WKWebView with unique client url
  • injected in window must be initialized with your wallet

Code Example

View Model

Kotlin (Android)

Integrate the widget into Android applications using WebView with custom wallet injection.

Implementation

  • Use WebView with unique client url
  • injected in window must be initialized with your wallet

Activity Code

View Model

Layout XML

React Native

Integrate the widget into React Native applications using react-native-webview.

Implementation

  • Use WebView with unique client url
  • injected in window must be initialized with your wallet

Code Example

Web Integration (No Custom Wallet)

For web applications where you don’t need custom wallet integration, use a simple iframe approach.

Implementation

  • Use iframe with unique client url
  • For wallet connection, RainbowKit is used internally

Code Example

Sending events from host to widget (postMessage)

If you embed the widget via an iframe and need to notify it about host-side events (e.g. theme change), use postMessage. Host → widget message format:
Supported message types:
  • setTheme with payload { theme: "light" | "dark" }
Security / origin allowlist: The widget validates event.origin. Configure allowed origins contacting our team.

Responsive Integration

Security Considerations

When integrating the widget across platforms, consider these security aspects:

JavaScript Injection

  • Always validate and sanitize any data before injecting JavaScript
  • Use secure communication channels between your app and the widget
  • Implement proper error handling for wallet injection failures

Network Security

  • Ensure HTTPS is used for all widget URLs
  • Implement certificate pinning where possible
  • Handle network failures gracefully

Wallet Security

  • Never expose private keys or sensitive wallet data
  • Use secure storage mechanisms for wallet credentials
  • Implement proper session management

Testing Integration

Platform-Specific Testing

iOS Testing:
  • Test on different iOS versions and device sizes
  • Verify WKWebView security settings
  • Test wallet injection scenarios
Android Testing:
  • Test on various Android versions and devices
  • Verify WebView security configurations
  • Test JavaScript bridge functionality
React Native Testing:
  • Test on both iOS and Android platforms
  • Verify WebView component behavior
  • Test navigation and state management
Web Testing:
  • Test iframe behavior across browsers
  • Verify responsive design
  • Test wallet connection flows

Troubleshooting

Common Issues

Wallet Injection Failures:
Network Connectivity:
Cross-Platform Compatibility:
  • Ensure URLs are properly formatted for each platform
  • Test deep linking and navigation flows
  • Verify consistent behavior across platforms