# Facebook

Canonical HTML: https://p-hatan.com/deeplink-x/apps/facebook/

DeeplinkX 1.5.8.

## Platforms and setup

Native platforms: **ios, android, windows**.



## Public actions

### Facebook.open


```dart
factory Facebook.open({final bool fallbackToStore = false})
```

Launch with `DeeplinkX.launchApp`. Native platforms: **ios, android, windows**. Action web fallback: **available**. Store-fallback flag: **supported; opt in explicitly**.

| Parameter | Type | Required | Default |
| --- | --- | --- | --- |
| `fallbackToStore` | `bool` | No | `false` |

[Exact source](https://github.com/DeepLinkX/DeeplinkX/blob/00d9d2c7c1affe4e2ee459a01afeba82a1480eac/lib/src/apps/downloadable_apps/facebook.dart#L22)

### Facebook.openProfileById


```dart
static FacebookOpenProfileByIdAction openProfileById({ required final String id, final bool fallbackToStore = false, })
```

Launch with `DeeplinkX.launchAction`. Native platforms: **ios, android, windows**. Action web fallback: **available**. Store-fallback flag: **supported; opt in explicitly**.

| Parameter | Type | Required | Default |
| --- | --- | --- | --- |
| `id` | `String` | Yes | — |
| `fallbackToStore` | `bool` | No | `false` |

[Exact source](https://github.com/DeepLinkX/DeeplinkX/blob/00d9d2c7c1affe4e2ee459a01afeba82a1480eac/lib/src/apps/downloadable_apps/facebook.dart#L65)

### Facebook.openProfileByUsername


```dart
static FacebookOpenProfileByUsernameAction openProfileByUsername({ required final String username, final bool fallbackToStore = false, })
```

Launch with `DeeplinkX.launchAction`. Native platforms: **ios, android, windows**. Action web fallback: **available**. Store-fallback flag: **supported; opt in explicitly**.

| Parameter | Type | Required | Default |
| --- | --- | --- | --- |
| `username` | `String` | Yes | — |
| `fallbackToStore` | `bool` | No | `false` |

[Exact source](https://github.com/DeepLinkX/DeeplinkX/blob/00d9d2c7c1affe4e2ee459a01afeba82a1480eac/lib/src/apps/downloadable_apps/facebook.dart#L83)

### Facebook.openPage


```dart
static FacebookOpenPageAction openPage({ required final String pageId, final bool fallbackToStore = false, })
```

Launch with `DeeplinkX.launchAction`. Native platforms: **ios, android, windows**. Action web fallback: **available**. Store-fallback flag: **supported; opt in explicitly**.

| Parameter | Type | Required | Default |
| --- | --- | --- | --- |
| `pageId` | `String` | Yes | — |
| `fallbackToStore` | `bool` | No | `false` |

[Exact source](https://github.com/DeepLinkX/DeeplinkX/blob/00d9d2c7c1affe4e2ee459a01afeba82a1480eac/lib/src/apps/downloadable_apps/facebook.dart#L101)

### Facebook.openGroup


```dart
static FacebookOpenGroupAction openGroup({ required final String groupId, final bool fallbackToStore = false, })
```

Launch with `DeeplinkX.launchAction`. Native platforms: **ios, android, windows**. Action web fallback: **available**. Store-fallback flag: **supported; opt in explicitly**.

| Parameter | Type | Required | Default |
| --- | --- | --- | --- |
| `groupId` | `String` | Yes | — |
| `fallbackToStore` | `bool` | No | `false` |

[Exact source](https://github.com/DeepLinkX/DeeplinkX/blob/00d9d2c7c1affe4e2ee459a01afeba82a1480eac/lib/src/apps/downloadable_apps/facebook.dart#L119)

### Facebook.openEvent


```dart
static FacebookOpenEventAction openEvent({ required final String eventId, final bool fallbackToStore = false, })
```

Launch with `DeeplinkX.launchAction`. Native platforms: **ios, android, windows**. Action web fallback: **available**. Store-fallback flag: **supported; opt in explicitly**.

| Parameter | Type | Required | Default |
| --- | --- | --- | --- |
| `eventId` | `String` | Yes | — |
| `fallbackToStore` | `bool` | No | `false` |

[Exact source](https://github.com/DeepLinkX/DeeplinkX/blob/00d9d2c7c1affe4e2ee459a01afeba82a1480eac/lib/src/apps/downloadable_apps/facebook.dart#L137)


## Provider setup and examples
DeeplinkX provides comprehensive support for Facebook deep linking actions.

## Available Actions

### Launch Facebook App
```dart
final deeplinkX = DeeplinkX();

// Simple launch
await deeplinkX.launchApp(Facebook.open());

// Launch with store fallback if not installed
await deeplinkX.launchApp(Facebook.open(fallbackToStore: true));

// Launch with fallback disabled
await deeplinkX.launchApp(Facebook.open(), disableFallback: true);
```

### Open Profile by ID Action
```dart
final deeplinkX = DeeplinkX();

// Simple action
await deeplinkX.launchAction(Facebook.openProfileById(id: 'profileId')); // Facebook numeric ID (e.g. '123456789')

// Action with store fallback if not installed
await deeplinkX.launchAction(Facebook.openProfileById(
  id: 'profileId', // Facebook numeric ID (e.g. '123456789')
  fallbackToStore: true,
));

// Action with fallback disabled
await deeplinkX.launchAction(
  Facebook.openProfileById(id: 'profileId'), // Facebook numeric ID (e.g. '123456789')
  disableFallback: true,
);
```

### Open Profile by Username Action
```dart
final deeplinkX = DeeplinkX();

// Simple action
await deeplinkX.launchAction(Facebook.openProfileByUsername(username: 'username')); // Facebook username (e.g. 'zuck' for Mark Zuckerberg)

// Action with store fallback if not installed
await deeplinkX.launchAction(Facebook.openProfileByUsername(
  username: 'username', // Facebook username (e.g. 'zuck' for Mark Zuckerberg)
  fallbackToStore: true,
));

// Action with fallback disabled
await deeplinkX.launchAction(
  Facebook.openProfileByUsername(username: 'username'), // Facebook username (e.g. 'zuck' for Mark Zuckerberg)
  disableFallback: true,
);
```

### Open Page Action
```dart
final deeplinkX = DeeplinkX();

// Simple action
await deeplinkX.launchAction(Facebook.openPage(pageId: 'pageId')); // Facebook page ID (e.g. 'facebookapp' for Facebook's official page)

// Action with store fallback if not installed
await deeplinkX.launchAction(Facebook.openPage(
  pageId: 'pageId', // Facebook page ID (e.g. 'facebookapp' for Facebook's official page)
  fallbackToStore: true,
));

// Action with fallback disabled
await deeplinkX.launchAction(
  Facebook.openPage(pageId: 'pageId'), // Facebook page ID (e.g. 'facebookapp' for Facebook's official page)
  disableFallback: true,
);
```

### Open Group Action
```dart
final deeplinkX = DeeplinkX();

// Simple action
await deeplinkX.launchAction(Facebook.openGroup(groupId: 'groupId')); // Facebook group ID (e.g. '231104380821004' for Flutter Community group)

// Action with store fallback if not installed
await deeplinkX.launchAction(Facebook.openGroup(
  groupId: 'groupId', // Facebook group ID (e.g. '231104380821004' for Flutter Community group)
  fallbackToStore: true,
));

// Action with fallback disabled
await deeplinkX.launchAction(
  Facebook.openGroup(groupId: 'groupId'), // Facebook group ID (e.g. '231104380821004' for Flutter Community group)
  disableFallback: true,
);
```

### Open Event Action
```dart
final deeplinkX = DeeplinkX();

// Simple action
await deeplinkX.launchAction(Facebook.openEvent(eventId: 'eventId')); // Facebook event ID (e.g. '10155945715431729' for F8 Conference)

// Action with store fallback if not installed
await deeplinkX.launchAction(Facebook.openEvent(
  eventId: 'eventId', // Facebook event ID (e.g. '10155945715431729' for F8 Conference)
  fallbackToStore: true,
));

// Action with fallback disabled
await deeplinkX.launchAction(
  Facebook.openEvent(eventId: 'eventId'), // Facebook event ID (e.g. '10155945715431729' for F8 Conference)
  disableFallback: true,
);
```

## Parameter Validations

### ID Validation
Facebook IDs must be valid numeric or alphanumeric identifiers assigned by Facebook.

### Username Validation
Facebook usernames must follow these rules:
- Length: 5-50 characters
- Can contain letters, numbers, and periods
- Cannot contain spaces or special characters
- Cannot start or end with a period
- Cannot contain consecutive periods

## Platform-Specific Configuration

### iOS
Add the following to your `ios/Runner/Info.plist`:
```xml
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fb</string>
    <string>itms-apps</string>
</array>
```

### Android
Add the following to your `android/app/src/main/AndroidManifest.xml` inside the `<queries>` tag:
```xml
<queries>
    <!-- For Facebook app -->
    <package android:name="com.facebook.katana" />
    
    <!-- For Play Store fallback (if using fallbackToStore) -->
    <package android:name="com.android.vending" />
    
    <!-- For web fallback (required) -->
    <intent>
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="https" />
    </intent>
</queries>
```

## URL Schemes

DeeplinkX uses the following URL schemes for Facebook:

### Native App Deep Links
When Facebook is installed, the following schemes are used:
- `fb://` - Native Facebook URL scheme
- For profiles by ID: `fb://profile/{id}`
- For profiles by username: `https://www.facebook.com/{username}` (uses universal link)
- For pages: `https://www.facebook.com/{pageId}` (uses universal link)
- For groups: `https://www.facebook.com/groups/{groupId}` (uses universal link)
- For events: `https://www.facebook.com/events/{eventId}` (uses universal link)

### Web Fallback URLs
When Facebook is not installed, DeeplinkX automatically falls back to:
- `https://www.facebook.com` - Official Facebook web URL
- For profiles by ID: `https://www.facebook.com/{id}`
- For profiles by username: `https://www.facebook.com/{username}`
- For pages: `https://www.facebook.com/{pageId}`
- For groups: `https://www.facebook.com/groups/{groupId}`
- For events: `https://www.facebook.com/events/{eventId}`

