Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Migrate Android Gradle config to plugins { } DSL using Flutter‑recommended approach
- Standardize payload schema
- Add PendingIntents and filter out non-notification intents
- Simplify URL launcher by removing canLaunchUrl check and Android manifest queries

## 1.0.0

Expand Down
47 changes: 2 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,30 +88,6 @@ Add at the very bottom:
apply plugin: 'com.google.gms.google-services'
```

#### 3. AndroidManifest.xml Updates (Optional)

**Most configuration is handled automatically by the plugin!** You only need to add the following if your app opens external URLs from notifications:

```xml
<!-- For opening external URLs (optional - only if your notifications contain links) -->
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
</queries>
```

**Note:** The plugin automatically handles:

- `POST_NOTIFICATIONS` permission
- Firebase messaging service registration
- Default notification channel setup

## Quick Start Guide

### 1. One-Line Setup
Expand Down Expand Up @@ -209,7 +185,7 @@ PntaFlutter.foregroundNotifications.listen((payload) {
}
});

// Remember to cancel subscriptions in dispose() to avoid memory leaks

```

#### Background/Terminated Notifications
Expand All @@ -222,7 +198,7 @@ PntaFlutter.onNotificationTap.listen((payload) {
// Links are auto-handled if autoHandleLinks is true
});

// Remember to cancel subscriptions in dispose() to avoid memory leaks

```

## API Reference
Expand Down Expand Up @@ -276,25 +252,6 @@ The plugin automatically routes links based on these rules:
- **Contains `://`** (e.g., `http://example.com`, `mailto:test@example.com`) → Opens externally via system browser/app
- **No `://`** (e.g., `/profile`, `/settings`) → Navigates internally using Flutter's Navigator

### Metadata Best Practices

Store your metadata in one place and use it consistently:

```dart
class UserMetadata {
static Map<String, dynamic> get current => {
'user_id': getCurrentUserId(),
'app_version': getAppVersion(),
'subscription_tier': getSubscriptionTier(),
'last_active': DateTime.now().toIso8601String(),
};
}

// Use everywhere
await PntaFlutter.initialize('prj_XXXXXXXXX', metadata: UserMetadata.current);
await PntaFlutter.updateMetadata(UserMetadata.current);
```

## Example

For a complete working example with all features, see the `example/` app in the plugin repository.
14 changes: 0 additions & 14 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
</queries>
<application
android:label="pnta_flutter_example"
android:name="${applicationName}"
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.0"
version: "1.1.0"
process:
dependency: transitive
description:
Expand Down
21 changes: 8 additions & 13 deletions lib/src/link_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,16 @@ class LinkHandler {
}

try {
if (link.contains('://')) {
final uri = Uri.parse(link);
if (await canLaunchUrl(uri)) {
final launched =
await launchUrl(uri, mode: LaunchMode.externalApplication);
if (launched) {
debugPrint('PNTA: Successfully launched URL: $link');
} else {
debugPrint('PNTA: Failed to launch URL: $link');
}
return launched;
final uri = Uri.parse(link);
if (uri.hasScheme) {
final launched =
await launchUrl(uri, mode: LaunchMode.externalApplication);
if (launched) {
debugPrint('PNTA: Successfully launched URL: $link');
} else {
debugPrint('PNTA: Cannot launch URL - no app available: $link');
return false;
debugPrint('PNTA: Failed to launch URL: $link');
}
return launched;
} else {
final navigator = PntaFlutter.navigatorKey.currentState;
if (navigator != null) {
Expand Down