Skip to content

Latest commit

 

History

History
285 lines (220 loc) · 7.45 KB

File metadata and controls

285 lines (220 loc) · 7.45 KB

THN Native SDK Troubleshooting Guide

This guide helps address common issues that might arise when integrating the THN Native SDK into your iOS or Android application.

Common Issues and Solutions

Widget Not Loading

Symptoms:

  • Blank space where the widget should appear
  • Error callbacks being triggered
  • No visible content in the widget area

Possible Causes & Solutions:

  1. Invalid Property ID

    • Ensure your property ID is correct and active
    • Verify with THN support that your property is configured correctly
  2. Network Connectivity Issues

    • Check your device has internet access
    • Ensure your app has proper network permissions
    • iOS: Check Info.plist for network permissions
    • Android: Verify INTERNET permission in your manifest
  3. Incorrect Page Type

    • Make sure you're using the appropriate THNPageName for the current screen
    • Different page types display different widgets; using the wrong one may result in no content
  4. Framework Integration Issues

    • iOS: Ensure the framework is properly embedded in your app
    • Android: Verify the AAR file is correctly included in your project

Memory Issues

Symptoms:

  • App crashes when navigating away from the widget screen
  • Memory warnings in the console
  • Performance degradation over time

Solutions:

  1. iOS Memory Management

    • Ensure proper lifecycle management of the THNWidgetLoader
    • For UIKit, properly remove the widget from view hierarchy when not needed
    • For SwiftUI, avoid creating multiple instances of the widget unnecessarily
    // In viewWillDisappear:
    widgetView.removeFromSuperview()
  2. Android Memory Management

    • Call destroy() on the widget when it's no longer needed
    • Handle configuration changes properly
    override fun onDestroy() {
        super.onDestroy()
        widgetLoader.destroy()
    }

Touch Events Not Working

Symptoms:

  • Widget is visible but doesn't respond to touch
  • Some elements in the widget are not interactive
  • Touch events are passed through to views behind the widget

Solutions:

  1. iOS Touch Handling

    • Ensure the widget view has userInteractionEnabled = true
    • Check if any views are overlapping the widget with higher z-index
    • Verify isUserInteractionEnabled is true for parent views
  2. Android Touch Handling

    • Make sure no other views are capturing touch events
    • Verify the widget is properly sized and visible
    • Check for any transparent overlays that might be intercepting touches

Debug Mode Issues

Symptoms:

  • Debug mode is enabled but no visual indicators appear
  • Console logs not showing in development environment

Solutions:

  1. iOS Debug Mode

    • Ensure debugMode parameter is set to true
    • Check that the debug console is visible in Xcode
    • Use Safari Developer Tools to inspect WebView content
    THNWidgetLoader(
        data: $thnData,
        error: $error,
        debugMode: true,  // Set debug mode
        isVisible: $isVisible
    )
  2. Android Debug Mode

    • Enable WebView debugging at the application level
    • Use Chrome DevTools to inspect WebView content
    // In your Application class:
    override fun onCreate() {
        super.onCreate()
        if (BuildConfig.DEBUG) {
            WebView.setWebContentsDebuggingEnabled(true)
        }
    }
    
    // When configuring the widget:
    widgetLoader.configure(
        data = thnData,
        debugMode = true,
        // other parameters
    )

Data Not Updating

Symptoms:

  • Widget doesn't reflect changes in your data models
  • Updates to THNData are not visible in the widget

Solutions:

  1. iOS Data Binding

    • Ensure your SwiftUI @State or @Binding properties are working correctly
    • Create a new THNData instance rather than modifying properties of an existing one
    • Verify your update is happening on the main thread
    // Instead of modifying properties:
    // thnData.search?.checkIn = "2023-07-01"  // May not trigger update
    
    // Create a new instance:
    thnData = THNData(
        propertyId: thnData.propertyId,
        pageName: thnData.pageName,
        languageCode: thnData.languageCode,
        currencyCode: thnData.currencyCode,
        search: THNSearch(
            checkIn: "2023-07-01",
            checkOut: thnData.search?.checkOut ?? ""
        )
    )
  2. Android Data Updates

    • Use the updateData() method to refresh the widget
    • Ensure you're creating a new THNData instance with updated values
    // Create updated data
    val updatedData = THNData(
        propertyId = currentData.propertyId,
        pageName = currentData.pageName,
        // Updated properties
        search = THNSearch(
            checkIn = "2023-07-01",
            checkOut = "2023-07-05"
        )
    )
    
    // Update the widget
    widgetLoader.updateData(updatedData)

Widget Visibility Issues

Symptoms:

  • Widget is not visible even though it's properly initialized
  • Widget appears but doesn't show expected content

Solutions:

  1. iOS Visibility

    • Check that the isVisible binding is set to true
    • Verify the widget is properly positioned in your view hierarchy
    • Ensure parent views don't have hidden = true or opacity = 0
  2. Android Visibility

    • Check the widget's visibility properties (View.VISIBLE)
    • Ensure the widget has proper layout dimensions
    • Verify parent layouts aren't hiding the widget

Date Format Issues

Symptoms:

  • Widget doesn't show correct dates
  • Booking functionality doesn't work as expected

Solutions:

  • Ensure all dates are formatted as "YYYY-MM-DD" (e.g., "2023-06-15")
  • Don't use localized date formats or different separators

Debugging Tips

Enable Debug Mode

Always start troubleshooting by enabling debug mode:

iOS:

THNWidgetLoader(
    data: $thnData,
    error: $error,
    debugMode: true,
    isVisible: $isVisible
)

Android:

widgetLoader.configure(
    data = thnData,
    debugMode = true,
    // other parameters
)

Inspect WebView Content

Both platforms allow inspecting the WebView content:

iOS:

  1. Connect your device/simulator to Safari
  2. Enable Web Inspector in Safari Developer Tools
  3. Select your app's WebView from the Develop menu

Android:

  1. Enable chrome://inspect in Chrome
  2. Connect your device/emulator
  3. Navigate to the screen with the THN widget
  4. Select your WebView from the list of targets

Check Console Logs

Enable verbose logging to see detailed information:

iOS:

// Add an observer for error binding changes
.onChange(of: error) { newError in
    if let error = newError {
        print("THN Widget Error: \(error.localizedDescription)")
    }
}

Android:

// Add a custom logger
widgetLoader.configure(
    data = thnData,
    debugMode = true,
    isVisible = { isVisible ->
        Log.d("THNWidget", "Visibility changed: $isVisible")
    }
)

Still Having Issues?

If you're still experiencing problems after trying these solutions:

  1. Check our sample applications for reference implementations:

    • iOS: ios/thnnative-ios-sample/
    • Android: android/app/
  2. Verify your data models match the expected formats (see DATA_MODELS.md)

  3. Contact THN support at tech@thehotelsnetwork.com with:

    • Your implementation code
    • Detailed error messages/logs
    • Steps to reproduce the issue
    • Device/OS/SDK version information