### Activity Result Launchers Setup Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/README.md Sets up ActivityResultLaunchers for handling results from starting activities, specifically for battery optimization and other permission-related intents. ```java overlayPermissionLauncher = registerForActivityResult( new ActivityResultContracts.StartActivityForResult(), result -> checkBatteryOptimizationPermission() ); batteryOptimizationLauncher = registerForActivityResult( new ActivityResultContracts.StartActivityForResult(), result -> { } ); ``` -------------------------------- ### React Native Build and Run Commands Source: https://context7.com/huvle-ad/huvleview_sdk_en/llms.txt Standard commands for installing dependencies, starting the Metro bundler, and building/running the Android application. Includes options for device selection and cleaning the build. ```bash # Install JS dependencies cd HuvleSDK_ReactNative/huvleSDKreactSample npm install # Start Metro bundler (Terminal 1) npx react-native start # Build and run on connected Android device (Terminal 2) npx react-native run-android # Run on a specific device by ID npx react-native run-android --deviceId=EMULATOR_5554 # Clean build on errors cd android && ./gradlew clean && cd .. npx react-native start --reset-cache ``` -------------------------------- ### Build and Run React Native App Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/HuvleSDK_ReactNative/HUVLE_INTEGRATION_GUIDE.md Commands to install dependencies, start the Metro bundler, and build/run the Android application. Includes options for specific devices and cleaning the build cache. ```bash # Navigate to the project directory cd HuvleSDK_ReactNative/huvleSDKreactSample # Install dependencies npm install # Start Metro bundler (Terminal 1) npx react-native start # Build and run on Android (Terminal 2) npx react-native run-android # Run on a specific device npx react-native run-android --deviceId=DEVICE_ID # Clean build cache on error cd android && ./gradlew clean && cd .. npx react-native start --reset-cache ``` -------------------------------- ### Gradle Dependency Setup (Kotlin DSL) Source: https://context7.com/huvle-ad/huvleview_sdk_en/llms.txt Configure your project's settings.gradle.kts to include the Huvle private Maven repository and your app/build.gradle.kts to declare the SDK and other necessary dependencies. A Material Components theme is required. ```kotlin // settings.gradle.kts dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() maven { name = "Huvle" url = uri("https://sdk.huvle.com/repository/internal") } } } // app/build.gradle.kts android { compileSdk = 35 defaultConfig { minSdk = 23 targetSdk = 35 } compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { jvmTarget = "17" } buildTypes { release { ndk { debugSymbolLevel = "SYMBOL_TABLE" } } debug { ndk { debugSymbolLevel = "SYMBOL_TABLE" } } } } dependencies { implementation("com.google.android.gms:play-services-ads-identifier:18.0.1") implementation("com.byappsoft.sap:HuvleSDK:6.3.0.2") implementation("androidx.activity:activity-ktx:1.8.0") implementation("com.google.android.material:material:1.12.0") } ``` -------------------------------- ### Gradle Dependency Setup (Groovy DSL) Source: https://context7.com/huvle-ad/huvleview_sdk_en/llms.txt Configure your project's settings.gradle to include the Huvle private Maven repository and your app/build.gradle to declare the SDK and other necessary dependencies. A Material Components theme is required. ```groovy // settings.gradle dependencyResolutionManagement { repositories { google() mavenCentral() maven { name "Huvle" url "https://sdk.huvle.com/repository/internal" } } } // app/build.gradle dependencies { implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1' implementation 'com.byappsoft.sap:HuvleSDK:6.3.0.2' implementation 'androidx.activity:activity:1.8.0' implementation 'com.google.android.material:material:1.12.0' } ``` -------------------------------- ### Start Metro Server Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/HuvleSDK_ReactNative/huvleSDKreactSample/README.md Start the Metro bundler, which is essential for running React Native applications. This command should be executed from the root of your project. ```bash # using npm npm start # OR using Yarn yarn start ``` -------------------------------- ### Sap_MainActivity / Sap_BrowserActivity Source: https://context7.com/huvle-ad/huvleview_sdk_en/llms.txt Launches the Huvle in-app browser to a specified URL. This is achieved by starting `Sap_MainActivity` or `Sap_BrowserActivity` with the URL passed as an extra. ```APIDOC ## `Sap_MainActivity` / `Sap_BrowserActivity` — In-App Browser Launch Opens the Huvle in-app browser pointed at a given URL. Use `Sap_BrowserActivity.PARAM_OPEN_URL` as the Intent extra key. ### Description Launches the in-app browser to a specified URL. ### Method `startActivity(Intent intent)` with `Sap_BrowserActivity.PARAM_OPEN_URL` extra. ### Parameters - **intent** (Intent) - Required - Intent to start the activity. - **`Sap_BrowserActivity.PARAM_OPEN_URL`** (String) - Required - The URL to open. ### Request Example ```kotlin val intent = Intent(this, Sap_MainActivity::class.java).apply { putExtra(Sap_BrowserActivity.PARAM_OPEN_URL, "https://www.huvle.com/global_set.php") } startActivity(intent) ``` ``` -------------------------------- ### Flutter Project Build and Run Commands Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/huvleflutter/HUVLE_INTEGRATION_GUIDE.md Common command-line interface commands for managing a Flutter project, including checking the environment, installing dependencies, running the app, and building release versions. ```bash # Navigate to the project directory cd Huvleflutter # Check Flutter environment flutter doctor # Install dependencies flutter pub get # Build and run on a connected device flutter run # Build Release APK flutter build apk --release # Build AAB (for Google Play upload) flutter build appbundle --release # Clean build cache on error flutter clean flutter pub get cd android && ./gradlew clean && cd .. flutter run ``` -------------------------------- ### Android MethodChannel Setup for Huvle SDK Source: https://context7.com/huvle-ad/huvleview_sdk_en/llms.txt Configure a MethodChannel in MainActivity.java to handle calls from Flutter. This setup exposes SDK functions like notiUpdate, notiCancel, and openBrowser to your Dart code. ```java import androidx.annotation.NonNull; import io.flutter.embedding.android.FlutterActivity; import io.flutter.embedding.engine.FlutterEngine; import io.flutter.plugins.GeneratedPluginRegistrant; import android.content.Intent; import android.os.Build; public class MainActivity extends FlutterActivity { private static final String CHANNEL = "com.huvle.sdk/huvle"; @Override public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { GeneratedPluginRegistrant.registerWith(flutterEngine); new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL) .setMethodCallHandler((call, result) -> { switch (call.method) { case "notiUpdate": Sap_Func.notiUpdate(getApplicationContext()); result.success(null); break; case "notiCancel": Sap_Func.notiCancel(getApplicationContext()); result.success(null); break; case "openBrowser": Intent intent = new Intent(this, Sap_MainActivity.class); intent.putExtra(Sap_BrowserActivity.PARAM_OPEN_URL, "https://www.huvle.com/global_set.php"); startActivity(intent); result.success(null); break; default: result.notImplemented(); } }); } @Override public void onResume() { super.onResume(); if (Build.VERSION.SDK_INT >= 34) Sap_Func.setServiceState(this, true); Sap_act_main_launcher.initsapStart(this, "YOUR_AGENT_KEY", true, true, new Sap_act_main_launcher.OnLauncher() { @Override public void onDialogOkClicked() {} @Override public void onDialogCancelClicked() {} @Override public void onInitSapStartapp() {} @Override public void onUnknown() {} }); } } ``` -------------------------------- ### Sap_act_main_launcher.initsapStart() Source: https://context7.com/huvle-ad/huvleview_sdk_en/llms.txt Initializes the Huvle SDK. This is the primary entry point for launching Huvle features. It requires an agent key and configuration flags for the notification bar and URL search. A callback interface is provided for handling initialization events. ```APIDOC ## `Sap_act_main_launcher.initsapStart()` — Java Equivalent Same initialization call from a Java Activity. ### Description Initializes the Huvle SDK with provided parameters and a callback for initialization events. ### Method `initsapStart(Context context, String agentKey, boolean useNotibar, boolean useUrlSearch, Sap_act_main_launcher.OnLauncher callback)` ### Parameters - **context** (Context) - Required - The Android context. - **agentKey** (String) - Required - Your unique agent key. - **useNotibar** (boolean) - Required - Whether to use the notification bar. - **useUrlSearch** (boolean) - Required - Whether to use URL search functionality. - **callback** (Sap_act_main_launcher.OnLauncher) - Required - Callback interface for initialization events. ### Request Example ```java Sap_act_main_launcher.initsapStart( this, "YOUR_AGENT_KEY", true, // useNotibar true, // useUrlSearch new Sap_act_main_launcher.OnLauncher() { @Override public void onDialogOkClicked() {} @Override public void onDialogCancelClicked(){} @Override public void onInitSapStartapp() {} @Override public void onUnknown() {} } ); ``` ``` -------------------------------- ### Initialize SDK in Activity's onResume() Source: https://context7.com/huvle-ad/huvleview_sdk_en/llms.txt Call `initsapStart()` in the `onResume()` method of your first Activity. Pass `true` for `useNotibar` to show the notification bar ad and `true` for `useUrlSearch` to enable URL search features. Implement `OnLauncher` for consent dialog events. ```kotlin // Kotlin — MainActivity.kt import com.byappsoft.sap.launcher.Sap_act_main_launcher import com.byappsoft.sap.utils.Sap_Func class MainActivity : AppCompatActivity() { override fun onResume() { super.onResume() // Android 14+ (API 34): must refresh service state before initializing if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { Sap_Func.setServiceState(this, true) } Sap_act_main_launcher.initsapStart( this, "YOUR_AGENT_KEY", // Agent key from agent.huvle.com true, // useNotibar: show notification bar ad true, // useUrlSearch: enable URL search object : Sap_act_main_launcher.OnLauncher { override fun onDialogOkClicked() { /* User accepted consent */ } override fun onDialogCancelClicked(){ /* User declined consent */ } override fun onInitSapStartapp() { /* SDK init complete */ } override fun onUnknown() { /* Unhandled state */ } } ) } } ``` -------------------------------- ### Configure Project Repositories (Groovy DSL) Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/README.md Sets up repositories for Gradle plugins and dependencies in a Groovy DSL project. Ensure the Huvle repository is included. ```groovy pluginManagement { repositories { google() mavenCentral() gradlePluginPortal() } } dependencyResolutionManagement { repositories { google() mavenCentral() maven { name "Huvle" url "https://sdk.huvle.com/repository/internal" } } } rootProject.name = "MyApp" include ':app' ``` -------------------------------- ### Configure Project Repositories (Kotlin DSL) Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/README.md Sets up repositories for Gradle plugins and dependencies in a Kotlin DSL project. Ensure the Huvle repository is included. ```kotlin pluginManagement { repositories { google() mavenCentral() gradlePluginPortal() } } dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() maven { name = "Huvle" url = uri("https://sdk.huvle.com/repository/internal") } } } rootProject.name = "MyApp" include(":app") ``` -------------------------------- ### Initialize Huvle SDK and Request Permissions in MainActivity Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/HuvleSDK_ReactNative/HUVLE_INTEGRATION_GUIDE.md This Kotlin code demonstrates the complete process of requesting necessary permissions (Notification, Overlay, Battery Optimization) and initializing the Huvle SDK within the `MainActivity`. It ensures permissions are checked sequentially and the SDK is initialized in `onResume()` for correct operation. ```kotlin // android/app/src/main/java/.../MainActivity.kt class MainActivity : ReactActivity() { private val REQ_PERMISSION_POST_NOTIFICATION = 1001 private val REQ_PERMISSION_OVERLAY = 1002 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) checkNotificationPermission() } // [Step 1] Notification permission check private fun checkNotificationPermission() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions( this, arrayOf(Manifest.permission.POST_NOTIFICATIONS), REQ_PERMISSION_POST_NOTIFICATION ) return } } checkDrawOverlayPermission() } override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { super.onRequestPermissionsResult(requestCode, permissions, grantResults) if (requestCode == REQ_PERMISSION_POST_NOTIFICATION) { checkDrawOverlayPermission() } } // [Step 2] Display over other apps permission private fun checkDrawOverlayPermission() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(this)) { val intent = Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:$packageName")) startActivityForResult(intent, REQ_PERMISSION_OVERLAY) } else { requestIgnoreBatteryOptimizations() } } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == REQ_PERMISSION_OVERLAY) { Handler(Looper.getMainLooper()).postDelayed({ requestIgnoreBatteryOptimizations() }, 500) } } // [Step 3] Battery optimization exemption private fun requestIgnoreBatteryOptimizations() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { val pm = getSystemService(POWER_SERVICE) as android.os.PowerManager if (!pm.isIgnoringBatteryOptimizations(packageName)) { try { val intent = Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, Uri.parse("package:$packageName")) startActivity(intent) } catch (e: Exception) { e.printStackTrace() } } } initHuvleSDK() } // [Step 4] Huvle SDK initialization private fun initHuvleSDK() { try { Sap_act_main_launcher.initsapStart(this, "bynetwork", false, true) } catch (e: Exception) { e.printStackTrace() } } // Initialize SDK in onResume() of the first screen (Main Activity) shown after app launch override fun onResume() { super.onResume() // Android 14+ service state refresh — required if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { Sap_Func.setServiceState(this, true) } initHuvleSDK() } override fun getMainComponentName(): String = "huvleSDKreactSample" override fun createReactActivityDelegate(): ReactActivityDelegate = DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled) } ``` -------------------------------- ### Initialize Huvleview SDK in Android Activity Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/README.md Initialize the SDK in `onResume()` of the first screen shown after app launch. Ensure Android 14+ service state is refreshed. Replace 'YOUR_AGENT_KEY' with your actual agent key. ```kotlin override fun onResume() { super.onResume() // Android 14+ service state refresh — required if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { Sap_Func.setServiceState(this, true) } huvleView() } private fun huvleView() { Sap_act_main_launcher.initsapStart( this, "YOUR_AGENT_KEY", // Agent key registered at agent.huvle.com true, // Whether to use notibar true, // Whether to use URL search object : Sap_act_main_launcher.OnLauncher { override fun onDialogOkClicked() { } override fun onDialogCancelClicked() { } override fun onInitSapStartapp() { } override fun onUnknown() { } } ) } ``` -------------------------------- ### Initialize HuvleView SDK Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/README.md Initializes the HuvleView SDK with agent key and configuration options for notibar and URL search. This should be called in the onResume() of the first screen shown after app launch. ```java public void huvleView() { Sap_act_main_launcher.initsapStart( this, "YOUR_AGENT_KEY", // Agent key registered at agent.huvle.com true, // Whether to use notibar true, // Whether to use URL search new Sap_act_main_launcher.OnLauncher() { ``` -------------------------------- ### Launch In-App Browser in Java Source: https://context7.com/huvle-ad/huvleview_sdk_en/llms.txt Opens the Huvle in-app browser pointed at a given URL. Use `Sap_BrowserActivity.PARAM_OPEN_URL` as the Intent extra key. ```java // Java Intent intent = new Intent(MainActivity.this, Sap_MainActivity.class); intent.putExtra(Sap_BrowserActivity.PARAM_OPEN_URL, "https://www.huvle.com/global_set.php"); startActivity(intent); ``` -------------------------------- ### Launch In-App Browser in Kotlin Source: https://context7.com/huvle-ad/huvleview_sdk_en/llms.txt Opens the Huvle in-app browser pointed at a given URL. Use `Sap_BrowserActivity.PARAM_OPEN_URL` as the Intent extra key. ```kotlin // Kotlin import com.byappsoft.sap.browser.Sap_BrowserActivity import com.byappsoft.sap.browser.Sap_MainActivity val intent = Intent(this, Sap_MainActivity::class.java).apply { putExtra(Sap_BrowserActivity.PARAM_OPEN_URL, "https://www.huvle.com/global_set.php") } startActivity(intent) ``` -------------------------------- ### Initialize Huvle SDK and Configure MethodChannel Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/huvleflutter/HUVLE_INTEGRATION_GUIDE.md Initialize the Huvle SDK in `onResume()` of the main activity and configure the MethodChannel for Flutter communication. Ensure necessary permissions are requested before initialization. ```java import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; import io.flutter.embedding.android.FlutterActivity; import io.flutter.embedding.engine.FlutterEngine; import io.flutter.plugin.common.GeneratedPluginRegistrant; import io.flutter.plugin.common.MethodChannel; // Assuming Sap_Func, Sap_MainActivity, Sap_BrowserActivity, Sap_act_main_launcher are available // import com.huvle.sdk.Sap_Func; // import com.huvle.sdk.Sap_MainActivity; // import com.huvle.sdk.Sap_BrowserActivity; // import com.huvle.sdk.Sap_act_main_launcher; public class MainActivity extends FlutterActivity { private static final String CHANNEL = "com.huvle.sdk/huvle"; private static final int REQ_PERMISSION_POST_NOTIFICATION = 1001; private boolean isPermissionFlowDone = false; @Override public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) { GeneratedPluginRegistrant.registerWith(flutterEngine); // Flutter ↔ Android MethodChannel setup new MethodChannel(flutterEngine.getBinaryMessenger(), CHANNEL) .setMethodCallHandler((call, result) -> { switch (call.method) { case "notiUpdate": // Sap_Func.notiUpdate(getApplicationContext()); result.success(null); break; case "notiCancel": // Sap_Func.notiCancel(getApplicationContext()); result.success(null); break; case "openBrowser": Intent intent = new Intent(this, Sap_MainActivity.class); intent.putExtra(Sap_BrowserActivity.PARAM_OPEN_URL, "https://www.huvle.com/global_set.php"); startActivity(intent); result.success(null); break; default: result.notImplemented(); break; } }); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // [Step 1] Notification permission (Android 13+) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { if (!checkPostNotificationPermission()) { requestPostNotificationPermission(); } } // [Step 2] Overlay → Battery optimization permission flow startPermissionFlow(); } // Initialize SDK in onResume() of the first screen (Main Activity) shown after app launch @Override public void onResume() { super.onResume(); // Android 14+ service state refresh — required if (Build.VERSION.SDK_INT >= 34) { // Sap_Func.setServiceState(this, true); } huvleView(); } public void huvleView() { // Sap_Func.setNotiBarLockScreen(this, false); Sap_act_main_launcher.initsapStart(this, "bynetwork", true, true, new Sap_act_main_launcher.OnLauncher() { @Override public void onDialogOkClicked() { checkDrawOverlayPermission(); } @Override public void onDialogCancelClicked() { } @Override public void onInitSapStartapp() { } @Override public void onUnknown() { } }); } // Placeholder methods for permission checks and requests private boolean checkPostNotificationPermission() { // Implementation needed return false; } private void requestPostNotificationPermission() { // Implementation needed } private void startPermissionFlow() { // Implementation needed for overlay and battery optimization permissions } private void checkDrawOverlayPermission() { // Implementation needed } // ... permission flow (checkDrawOverlayPermission, checkBatteryOptimizationPermission, etc.) } ``` -------------------------------- ### Configure Project-Level Gradle Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/HuvleSDK_ReactNative/HUVLE_INTEGRATION_GUIDE.md Add Huvle's Maven repository and necessary build configurations to the project-level build.gradle file. ```groovy // android/build.gradle buildscript { ext { buildToolsVersion = "35.0.0" minSdkVersion = 24 compileSdkVersion = 36 targetSdkVersion = 35 ndkVersion = "26.1.10909125" kotlinVersion = "1.9.24" } repositories { google() mavenCentral() } dependencies { classpath("com.android.tools.build:gradle") classpath("com.facebook.react:react-native-gradle-plugin") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin") } } allprojects { repositories { google() maven { name "Huvle" url "https://sdk.huvle.com/repository/internal" } mavenCentral() } } ``` -------------------------------- ### Configure Gradle Wrapper Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/huvleflutter/HUVLE_INTEGRATION_GUIDE.md Specify the Gradle version in `android/gradle/wrapper/gradle-wrapper.properties`. ```properties distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip ``` -------------------------------- ### Flutter UI Implementation with Huvle SDK Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/huvleflutter/HUVLE_INTEGRATION_GUIDE.md Sets up the main Flutter application and a sample page with buttons to interact with the Huvle SDK via MethodChannel. Ensure the MethodChannel name 'com.huvle.sdk/huvle' matches the native implementation. ```dart import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( title: 'HuvleSDK Flutter', theme: ThemeData(primarySwatch: Colors.blue), home: const HuvleSamplePage(), ); } } class HuvleSamplePage extends StatelessWidget { const HuvleSamplePage({Key? key}) : super(key: key); static const _channel = MethodChannel('com.huvle.sdk/huvle'); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('Huvle SDK Sample'), centerTitle: true), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ // Notibar ON ElevatedButton( onPressed: () => _channel.invokeMethod('notiUpdate'), style: ElevatedButton.styleFrom(backgroundColor: Colors.green), child: const Text('Huvle ON / Update'), ), const SizedBox(height: 16), // Notibar OFF ElevatedButton( onPressed: () => _channel.invokeMethod('notiCancel'), style: ElevatedButton.styleFrom(backgroundColor: Colors.red), child: const Text('Huvle OFF'), ), const SizedBox(height: 16), // Open browser ElevatedButton( onPressed: () => _channel.invokeMethod('openBrowser'), style: ElevatedButton.styleFrom(backgroundColor: Colors.blue), child: const Text('Open Huvle Browser'), ), ], ), ), ); } } ``` -------------------------------- ### Custom Notibar Configuration (Java) Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/README.md Implement this class in Java to customize the notibar's appearance and behavior. The package path must exactly match 'com.byappsoft.sap'. ```java // File location: com/byappsoft/sap/CustomNotibarConfig.java package com.byappsoft.sap; import android.app.Activity; import com.byappsoft.sap.launcher.NotibarConfig; public class CustomNotibarConfig extends NotibarConfig { // Notibar icon (1–5, drawable resource ID) @Override public int getNotibarIcon1() { return R.drawable.your_noti_icon; } // Notibar text (1–5, string resource ID) @Override public int getNotibarString1() { return R.string.your_custom_string; } // Notibar button click action (1–5) @Override public void callNotibar1(Activity activity, String nt) { // Action to perform when notibar button is clicked } } ``` -------------------------------- ### Activity Configuration for Huvle SDK Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/README.md Configure your MainActivity with launchMode and clearTaskOnLaunch to ensure correct app launching behavior when using the Huvle SDK. ```xml ``` -------------------------------- ### Custom Notibar Configuration (Kotlin) Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/README.md Implement this class to customize the notibar's appearance and behavior. The package path must exactly match 'com.byappsoft.sap'. ```kotlin // File location: com/byappsoft/sap/CustomNotibarConfig.kt package com.byappsoft.sap import android.app.Activity import com.byappsoft.sap.launcher.NotibarConfig class CustomNotibarConfig : NotibarConfig() { // Consent dialog background image (drawable resource ID) override fun getNotibarPopupBg(): Int = R.drawable.your_popup_bg // Notibar icon (1–5, drawable resource ID) override fun getNotibarIcon1(): Int = R.drawable.your_noti_icon // Notibar text (1–5, string resource ID) override fun getNotibarString1(): Int = R.string.your_custom_string // Notibar button click action (1–5) override fun callNotibar1(activity: Activity, nt: String) { // Action to perform when notibar button is clicked // e.g., activity.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://example.com"))) // activity.finish() } } ``` -------------------------------- ### Initialize Huvle SDK in Java Activity Source: https://context7.com/huvle-ad/huvleview_sdk_en/llms.txt Use this call to initialize the Huvle SDK from a Java Activity. Ensure to handle Android 14+ service state refresh before this call if applicable. ```java // Java — MainActivity.java import com.byappsoft.sap.launcher.Sap_act_main_launcher; import com.byappsoft.sap.utils.Sap_Func; public class MainActivity extends AppCompatActivity { @Override public void onResume() { super.onResume(); // Android 14+ service state refresh if (Build.VERSION.SDK_INT >= 34) { Sap_Func.setServiceState(this, true); } Sap_act_main_launcher.initsapStart( this, "YOUR_AGENT_KEY", true, // useNotibar true, // useUrlSearch new Sap_act_main_launcher.OnLauncher() { @Override public void onDialogOkClicked() {} @Override public void onDialogCancelClicked(){} @Override public void onInitSapStartapp() {} @Override public void onUnknown() {} } ); } } ``` -------------------------------- ### Handle 'Display over other apps' Permission Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/README.md Prompts the user to grant 'Display over other apps' permission if not already enabled. If denied, it shows a toast message and proceeds to check battery optimization. This requires the `overlayPermissionLauncher` to be registered. ```kotlin private fun checkDrawOverlayPermission() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(this)) { AlertDialog.Builder(this).apply { setTitle("Display over other apps") setMessage("Permission to 'Display over other apps' is required to provide smooth service.") setPositiveButton("Go to Settings") { _, _ -> overlayPermissionLauncher.launch( Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION).apply { data = Uri.parse("package:$packageName") } ) } setNegativeButton("Cancel") { _, _ -> Toast.makeText(this@MainActivity, "Some features may be limited because the permission was denied.", Toast.LENGTH_SHORT).show() checkBatteryOptimizationPermission() } setCancelable(false) }.create().show() } else { checkBatteryOptimizationPermission() } } ``` -------------------------------- ### JavaScript/TypeScript Usage Source: https://context7.com/huvle-ad/huvleview_sdk_en/llms.txt Demonstrates how to import and use the native `BrowserModule` methods from React Native components. ```APIDOC ## React Native — JavaScript / TypeScript Usage ```tsx import React from 'react'; import { NativeModules, TouchableOpacity, Text, View, StyleSheet } from 'react-native'; const { BrowserModule } = NativeModules; export default function App() { return ( BrowserModule.openNotificationSettings()}> Huvle ON / Update BrowserModule.turnOffNotification()}> Huvle OFF BrowserModule.openSapMainActivity()}> Open Huvle Browser ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', gap: 16 }, btn: { paddingHorizontal: 24, paddingVertical: 12, borderRadius: 8 }, label: { color: '#fff', fontWeight: '600' }, }); ``` ``` -------------------------------- ### Configure App-Level Gradle Dependencies Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/HuvleSDK_ReactNative/HUVLE_INTEGRATION_GUIDE.md Add Huvle SDK and its required library dependencies to the app-level build.gradle file. ```groovy // android/app/build.gradle dependencies { implementation("com.facebook.react:react-android") // Huvle SDK & Dependencies implementation 'com.byappsoft.sap:HuvleSDK:6.3.0.2' implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1' implementation 'androidx.activity:activity:1.8.0' } ``` -------------------------------- ### Configure Gradle Settings Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/huvleflutter/HUVLE_INTEGRATION_GUIDE.md Configure Flutter plugin and AGP version in `android/settings.gradle`. Ensure `flutter.sdk` is set in `local.properties`. ```groovy pluginManagement { def flutterSdkPath = { def properties = new Properties() file("local.properties").withInputStream { properties.load(it) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" return flutterSdkPath }() includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") repositories { google() mavenCentral() gradlePluginPortal() } } plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "8.7.1" apply false } include ':app' ``` -------------------------------- ### Configure Android Manifest Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/huvleflutter/HUVLE_INTEGRATION_GUIDE.md Add necessary permissions and configure the Huvle NotiBar Service in `AndroidManifest.xml`. For versions v6.3.0.1+, the service block is optional. ```xml ``` -------------------------------- ### Add Permissions to AndroidManifest.xml Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/HuvleSDK_ReactNative/HUVLE_INTEGRATION_GUIDE.md Declare necessary permissions and configure the Huvle NotiBar Service in the AndroidManifest.xml file. ```xml ``` -------------------------------- ### Add ProGuard Rules for SDK Classes Source: https://context7.com/huvle-ad/huvleview_sdk_en/llms.txt Include these rules in `proguard-rules.pro` to prevent the stripping or obfuscation of SDK classes during release builds. ```proguard # proguard-rules.pro -keep class com.byappsoft.sap.** { *; } -dontwarn com.byappsoft.sap.** ``` -------------------------------- ### Apply Huvle SDK to Unity Project Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/huvleunity/Unity3D ReadMe.md This C# script is used to manage the Huvle SDK's lifecycle within a Unity application, specifically handling the resume functionality when the application gains focus. Ensure the HuvleSDK.aar is correctly placed in the Assets/Plugins/Android folder. ```csharp using System.Collections; using System.Collections.Generic; using UnityEngine; using System; public class HuvleSdkController : MonoBehaviour { void OnApplicationFocus(bool hasFocus) { if (hasFocus) { CallHuvleOnResume(); } } private void CallHuvleOnResume() { try { AndroidJavaClass unity_player = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject activity = unity_player.GetStatic("currentActivity"); AndroidJavaClass share_plugin = new AndroidJavaClass("com.byappsoft.sap.UnityInterface"); activity.Call("runOnUiThread", new AndroidJavaRunnable(() => { share_plugin.CallStatic("onResume", activity); })); } catch (Exception ex) { Debug.Log("CallHuvleOnResume error:" + ex.Message); } } } ``` -------------------------------- ### Configure Network Security to Allow HTTP Traffic Source: https://context7.com/huvle-ad/huvleview_sdk_en/llms.txt Create `res/xml/network_security_config.xml` to permit cleartext traffic for ad images and tracking resources served over HTTP. ```xml ``` -------------------------------- ### BrowserModule Native Module (Kotlin) Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/HuvleSDK_ReactNative/HUVLE_INTEGRATION_GUIDE.md Implements native functionalities for the Huvle SDK, such as opening notification settings, turning off notifications, and opening the Huvle browser. Requires Android API level checks for notification settings. ```kotlin import android.Manifest import android.content.Intent import android.content.pm.PackageManager import android.net.Uri import android.os.Build import android.provider.Settings import androidx.core.content.ContextCompat import androidx.core.app.NotificationManagerCompat import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.bridge.ReactContextBaseJavaModule import com.facebook.react.bridge.ReactMethod import com.facebook.react.module.annotations.ReactModule @ReactModule(name = "BrowserModule") class BrowserModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) { override fun getName(): String = "BrowserModule" @ReactMethod // Notibar ON / Update fun openNotificationSettings() { if (checkPermission()) { val context = reactApplicationContext if (!NotificationManagerCompat.from(context).areNotificationsEnabled()) { // Navigate to system settings if notifications are disabled val intent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS).apply { putExtra(Settings.EXTRA_APP_PACKAGE, context.packageName) } } else { Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply { data = Uri.parse("package:${context.packageName}") } } intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) context.startActivity(intent) } else { context.runOnUiQueueThread { Sap_Func.notiUpdate(context) } } } } @ReactMethod // Notibar OFF fun turnOffNotification() { reactApplicationContext.runOnUiQueueThread { Sap_Func.notiCancel(reactApplicationContext) } } @ReactMethod // Open Huvle browser fun openSapMainActivity() { val context = reactApplicationContext val intent = Intent(context, Sap_MainActivity::class.java).apply { putExtra(Sap_BrowserActivity.PARAM_OPEN_URL, "https://www.huvle.com/global_set.php") addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) } context.startActivity(intent) } private fun checkPermission(): Boolean { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { return ContextCompat.checkSelfPermission( reactApplicationContext, Manifest.permission.POST_NOTIFICATIONS ) == PackageManager.PERMISSION_GRANTED } return true } } ``` -------------------------------- ### Run iOS Application Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/HuvleSDK_ReactNative/huvleSDKreactSample/README.md Build and run your React Native application on an iOS simulator or device. Ensure the Metro server is running in a separate terminal. ```bash # using npm npm run ios # OR using Yarn yarn ios ``` -------------------------------- ### Request Battery Optimization Permission (Java) Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/README.md Initiates the process to request the user to grant 'Ignore battery optimizations' permission. It constructs an intent to either request specific app optimization or open the general settings. ```java private void checkBatteryOptimizationPermission() { if (isFinishing() || isDestroyed()) return; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Exclude from Battery Optimization"); builder.setMessage("For stable background operation of the app, you need to set this app to 'Don't optimize' in the 'Battery usage optimization' list."); builder.setPositiveButton("Go to Settings", (dialog, which) -> { Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); intent.setData(Uri.parse("package:" + getPackageName())); try { batteryOptimizationLauncher.launch(intent); } catch (Exception e) { batteryOptimizationLauncher.launch(new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS)); } }); builder.setNegativeButton("Cancel", (dialog, which) -> { Toast.makeText(this, "Some features may be limited because the permission was denied.", Toast.LENGTH_SHORT).show(); }); builder.setCancelable(false); builder.create().show(); } ``` -------------------------------- ### Call Huvle SDK from React Native (TypeScript) Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/HuvleSDK_ReactNative/HUVLE_INTEGRATION_GUIDE.md Demonstrates how to import and call native module methods (openNotificationSettings, turnOffNotification, openSapMainActivity) from a React Native component using the NativeModules API. ```typescript import React from 'react'; import { SafeAreaView, StatusBar, StyleSheet, Text, TouchableOpacity, View, NativeModules, } from 'react-native'; const { BrowserModule } = NativeModules; function App(): React.JSX.Element { return ( Huvle SDK Sample BrowserModule.openNotificationSettings()}> Huvle ON / Update BrowserModule.turnOffNotification()}> Huvle OFF BrowserModule.openSapMainActivity()}> Open Huvle Browser ); } ``` -------------------------------- ### Add Dependencies to Unity Gradle Template Source: https://github.com/huvle-ad/huvleview_sdk_en/blob/main/huvleunity/Unity3D ReadMe.md This snippet shows how to add necessary dependencies (appcompat, support-v4, play-services-ads-identifier) to the main Gradle template file in Unity. This is crucial for the Huvle SDK to function correctly. ```gradle . . dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:support-v4:28.0.0' implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1' **DEPS**} ```