Source: https://nishanth-fern-test.docs-staging.pageloop.ai/mobile/launch-via-notification

# Launch a project using Notification

- [Step 1: Generate the Project ID](/mobile/launch-via-notification#generate)
- [Step 2: Create a Cloud Notification](/mobile/launch-via-notification#cloud-notif)
- [Step 3: Launch Whatfix Mobile via notification](/mobile/launch-via-notification#launch)
- [Step 4: Run on your device](/mobile/launch-via-notification#device)

## Generate the Project ID

Generate the `project_id` of the project which you want to launch via a notification. For more information, see [Publish using Project ID](/mobile/publish-using-project-id).

> [!INFO]
>
> Ensure to send the correct `project_id` with the correct app version in the notification.

## Create a Cloud Notification

For this example, consider a notification created using Firebase.

1. **Compose a notification**. ![firebase\_notif](/images/ac/firebase_notif-ac8b506c.png)
2. Add the Whatfix Mobile **project ID**. ![firebase\_project\_id](/images/fe/firebase_project_id-fe4cb317.png)

Before publishing the notification, you need to add a code snippet in the Android project to launch the Whatfix Mobile project via the created notification.

## Launch Whatfix Mobile via Notification

To launch the Whatfix Mobile project via notification, you have to process the `project_id` passed in the Firebase dashboard, inside your Android project.

1. **Process the Firebase data in your Firebase service class**

**Android**

```plaintext
public class LeapFirebaseService extends FirebaseMessagingService {

   @Override
   public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);

        RemoteMessage.Notification remoteNotification = remoteMessage.getNotification();
        if (remoteNotification != null) {

            //1. Receive the data from Firebase
            Map<String, String> data = remoteMessage.getData();
            String projectId = data.get("project_id");

            //2. Create an intent (with project_id data as extra) and specify the destination
            Intent intent = new Intent(this, DestinationActivity.class);
            intent.putExtra("project_id", projectId);

            //3. Since we are launching a notification, we need to create a PendingIntent
            PendingIntent pendingIntent = PendingIntent.getActivity(this,
                    REQUEST_CODE,
                    intent,
                    PendingIntent.FLAG_UPDATE_CURRENT);

            //4. Create a notification with the above created PendingIntent
            Notification notification = getNotification(this,
                    remoteNotification.getTitle(),
                    remoteNotification.getBody(),
                    "Launch",
                    pendingIntent); // "Launch" is the action button text

            //5. Let's launch the notification
            NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            notificationManager.notify(NOTIFICATION_ID, notification);
        }
    }
    }
```

**Swift**

```plaintext
import UIKit
import Firebase
import FirebaseMessaging
import UserNotifications

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.

        FirebaseApp.configure()

        Messaging.messaging().delegate = self

        UNUserNotificationCenter.current().delegate = self

        let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]

        UNUserNotificationCenter.current().requestAuthorization(
                options: authOptions,
                completionHandler: { _, _ in }
            )

        application.registerForRemoteNotifications()

        return true
    }
```

1. **Launch the Whatfix Mobile project** Launch the project in the destination screen using `Leap.embedProject(String project_id)`.

**Android**

```plaintext
class DestinationActivity extends Activity {

  @Override
  protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    //1. Since the intent destination was here, we will handle the received intent here
    if (intent != null && intent.hasExtra("project_id")) {

       //2. Get the project_id from intent
       String projectId = intent.getStringExtra("project_id");

       //3. Verify the project_id is not null or not empty
      if (projectId != null && !projectId.isEmpty()) {

        //4. Launch the project_id via Leap SDK's 'embedProject' method
        Leap.embedProject(projectId);
      }
    }
  }
}
```

**Swift**

```plaintext
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {

          if let projectId = userInfo["projectId"] as? String {
          Leap.shared.embedProject(projectId)
        }
    }
```

## Run on your device

1. **Publish the notification**

![](/images/5d/firebase_publish-5d75b2e2.png)

1. **Check your app** When a notification comes up on your app, view the Whatfix Mobile content.

**Android**

![](/images/63/notification_android-63751292.png)

**iOS**

![](/images/6b/notification_ios-6b6452af.png)
