---
title: "Install Brainfish in a Mobile App"
description: "Overview"
canonical_url: "https://help.brainfi.sh/articles/install-brainfish-in-a-mobile-app-fAgxK7zwmD"
md_url: "https://help.brainfi.sh/articles/install-brainfish-in-a-mobile-app-fAgxK7zwmD.md"
---
# Install Brainfish in a Mobile App

## Overview

This guide outlines the steps to install Brainfish in mobile applications for both iOS and Android platforms, as well as React Native. The Brainfish agent will be displayed using a WebView or an iframe in full screen.

## Prerequisites

* Ensure you have the necessary permissions to modify your mobile app.
* Obtain your unique `YOURAGENTKEY` from the Brainfish dashboard.
  * 
     ![Where to find your unique agent key](https://help.brainfi.sh/api/attachments.redirect?id=f329670f-612e-440a-b519-58e3339f4be2 " =781x690")

## Installation Steps

### For iOS


1. **Open Xcode** and your project.
2. **Import WebKit Framework**: Go to your project settings, select your target, then navigate to "Build Phases" > "Link Binary with Libraries" and add WebKit.framework if it's not already included.
3. **Add a WebView**:
   * Open your ViewController.swift file.
   * Import WebKit at the top:

     ```swift
     import WebKit
     ```
   * Create a WKWebView instance:

     ```swift
     var webView: WKWebView!
     ```
   * Initialize the WebView and load the Brainfish URL:

     ```swift
     override func viewDidLoad() {
         super.viewDidLoad()
         webView = WKWebView(frame: self.view.frame)
         self.view.addSubview(webView)
         let url = URL(string: \"https://agent.brainfi.sh/?widgetKey=YOURAGENTKEY\")!
         webView.load(URLRequest(url: url))
     }
     ```
4. **Run your Application**: Build and run your app on a physical device or simulator to test the integration.

### For Android


1. **Open Android Studio** and your project.
2. **Modify AndroidManifest.xml**: Add internet permission if not already present:

   ```xml
   <uses-permission android:name=\"android.permission.INTERNET\" />
   ```
3. **Add a WebView** in your Activity layout (activity_main.xml):

   ```xml
   <WebView
       android:id=\"@+id/webview\"
       android:layout_width=\"match_parent\"
       android:layout_height=\"match_parent\" />
   ```
4. **Initialize and Load the WebView** in your MainActivity.java:

   ```java
   import android.os.Bundle;
   import android.webkit.WebSettings;
   import android.webkit.WebView;
   import androidx.appcompat.app.AppCompatActivity;
   
   public class MainActivity extends AppCompatActivity {
       private WebView myWebView;
   
       @Override
       protected void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.activity_main);
           myWebView = (WebView) findViewById(R.id.webview);
           WebSettings webSettings = myWebView.getSettings();
           webSettings.setJavaScriptEnabled(true);
           myWebView.loadUrl(\"https://agent.brainfi.sh/?widgetKey=YOURAGENTKEY\");
       }
   }
   ```
5. **Run your Application**: Test it on an emulator or physical device.

### For React Native


1. **Install WebView**: If you haven't already, install the React Native WebView package:

   ```bash
   npm install react-native-webview --save
   ```
2. **Implement WebView in your Component**:

   ```javascript
   import React from 'react';
   import { WebView } from 'react-native-webview';
   
   const App = () => {
       return (
           <WebView 
               source={{ uri: 'https://agent.brainfi.sh/?widgetKey=YOURAGENTKEY' }}
               style={{ flex: 1 }}
           />
       );
   };
   
   export default App;
   ```
3. **Run your Application**: Use the terminal command to start your app and ensure it displays the Brainfish agent correctly.

### FAQs

**Q: Which mobile platforms can I integrate Brainfish into for my mobile app?**
**A:** Brainfish can be integrated into mobile applications on iOS, Android, and React Native platforms. This flexibility supports a wide range of mobile developers, from beginners to seasoned professionals.

**Q: How do I obtain my unique agent key for Brainfish integration in my mobile app?**
**A:** To acquire your unique agent key for Brainfish, log into the Brainfish dashboard after setting up your account, then navigate to Agents > Select/Create an agent > Open Code tab on the righthand side to find your key. This key is essential for both developers who will implement it in the code and non-technical users who need it for setup or configuration.

 ![Where to find your unique agent key](https://help.brainfi.sh/api/attachments.redirect?id=f329670f-612e-440a-b519-58e3339f4be2 " =781x690")

**Q: Is it necessary to enable JavaScript for the Brainfish integration within my mobile application?**
**A:** Yes, enabling JavaScript in your WebView settings is crucial for all Brainfish features to function properly. This step ensures that your app delivers a smooth user experience, which is important for technical developers configuring functionality and non-technical users ensuring the app runs smoothly.

**Q: Can I test the Brainfish integration on an emulator when developing my mobile app?**
**A:** Yes, you can test the Brainfish integration on both physical devices and emulators for iOS and Android platforms. This allows developers to debug and refine the implementation while providing non-technical users confidence in the app's performance before deployment.

**Q: What specific permissions do I need to grant to integrate Brainfish into my mobile application?**
**A:** You must have the appropriate permissions to modify your mobile app. Specifically for Android, it's crucial to include internet permission in your manifest file so that the Brainfish agent loads correctly.
