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
27 changes: 27 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Pull Request Pipeline

on:
pull_request:
branches: [main, master]

jobs:
pull_request_pipeline:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: "3.32.0"
channel: "stable"
cache: true

- name: Install dependencies
run: flutter pub get

- name: Verify formatting
run: dart format --output=none --set-exit-if-changed .

- name: Analyze project source
run: flutter analyze
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
Expand Down Expand Up @@ -43,6 +45,7 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release
/android/.gradle/

# iOS/macOS
**/ios/**/*.mode1v3
Expand Down Expand Up @@ -137,4 +140,9 @@ Thumbs.db
*.tar.gz
*.zip
*.rar
*.7z
*.7z

# Example app specific
example/.metadata
example/pubspec.lock
example/.dart_tool/
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

All notable changes to this project will be documented in this file.

## [2.0.5] - 2024-03-21

### Changed

- 📦 **Package update** - Provided better utility methods for push token management

## [2.0.4] - 2024-03-21

### Fixed

- 🔧 **Permission handling** - Fixed issue where notification permission is revoked but was previously granted

## [2.0.2] - 2024-12-20

### Fixed
Expand Down
21 changes: 21 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Contributing to NotificationAPI Flutter SDK

## Publishing Locally

To publish the package locally for testing:

1. Update version in `pubspec.yaml`
2. Update changelog in `CHANGELOG.md`
3. Publish to local pub cache:

```bash
flutter pub publish --dry-run # Test first
flutter pub publish
```

## Development

1. Fork the repository
2. Create your feature branch
3. Make your changes
4. Submit a pull request
3 changes: 3 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
analyzer:
exclude:
- "example/**"
45 changes: 45 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
190 changes: 190 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
# NotificationAPI Flutter SDK Example

This example app demonstrates how to integrate and test the NotificationAPI Flutter SDK locally without publishing to pub.dev.

## Setup Instructions

### 1. Prerequisites

- Flutter SDK installed (3.0.0 or higher)
- iOS Simulator/Android Emulator or physical device
- NotificationAPI account and client ID

### 2. Configure the Example App

1. **Update Client ID**: Open `lib/main.dart` and replace the hardcoded values:

```dart
String _userId = 'user123'; // Change to your test user ID
String _clientId = 'your-client-id-here'; // Change to your actual client ID
```

2. **Configure for iOS** (if testing on iOS):

- Open `ios/Runner.xcworkspace` in Xcode
- Configure push notification capabilities
- Add your provisioning profile and signing

3. **Configure for Android** (if testing on Android):
- Add your `google-services.json` file to `android/app/`
- Ensure Firebase is properly configured

### 3. Run the Example

```bash
cd example
flutter run
```

## Features Demonstrated

The example app showcases all major SDK features:

### ✅ Initialization

- Simple one-call setup with `NotificationAPI.setup()`
- Configuration options (client ID, user ID, permissions, foreground notifications)

### ✅ Permission Management

- Automatic permission requests
- Manual permission requests
- Permission status monitoring

### ✅ Notification Handling

- Foreground notification display
- Background notification handling
- Notification tap handling
- Deep link support

### ✅ User Management

- User identification
- Token synchronization
- Device information collection

### ✅ Configuration Options

- Toggle foreground notifications on/off
- Real-time status monitoring
- Debug logging

## How to Test

### Basic Flow

1. **Configure**: Enter your client ID and user ID
2. **Initialize**: Tap "Initialize SDK" to set up the SDK
3. **Grant Permission**: Tap "Request Permission" if needed
4. **Send Test Notification**: Use your NotificationAPI dashboard to send a test notification
5. **Observe**: Check the "Notifications" tab to see received notifications

### Testing Scenarios

#### Scenario 1: Foreground Notifications

1. Keep the app open
2. Send a notification from your dashboard
3. Verify it appears both as a native notification and in the app's notification list

#### Scenario 2: Background Notifications

1. Send the app to background (home button)
2. Send a notification
3. Verify the native notification appears
4. Tap the notification to open the app
5. Check the "Notifications" tab

#### Scenario 3: App Terminated

1. Force close the app
2. Send a notification
3. Tap the notification to launch the app
4. Verify the notification appears in the "Notifications" tab

#### Scenario 4: Permission Scenarios

1. Test with permission granted
2. Test with permission denied
3. Test with permission initially denied, then granted later

## Debugging

### Logs Tab

The "Logs" tab shows real-time debug information including:

- SDK initialization status
- Permission requests and responses
- Token generation events
- Error messages

### Console Logs

Check the Flutter console/logs for additional debugging information:

```bash
flutter logs
```

## Common Issues

### Import Errors

If you see import errors, ensure you've run:

```bash
flutter pub get
```

### Permission Issues

- **iOS**: Ensure proper provisioning and capabilities are configured
- **Android**: Verify Firebase configuration and google-services.json

### Notifications Not Received

1. Check your client ID is correct
2. Verify user ID matches what you're targeting
3. Ensure device has internet connection
4. Check NotificationAPI dashboard for delivery status

## Local Development

This example uses the local SDK via:

```yaml
notificationapi_flutter_sdk:
path: ../
```

This means any changes you make to the main SDK will be reflected immediately in the example app with hot reload.

## Testing Different Configurations

You can modify the hardcoded values and initialization parameters in `main.dart` to test different configurations:

```dart
// Change these values in the class
String _userId = 'your-test-user';
String _clientId = 'your-actual-client-id';

// Modify setup parameters in _initializeNotificationAPI()
await NotificationAPI.setup(
clientId: _clientId,
userId: _userId,
hashedUserId: 'optional-hashed-id', // Add this for privacy
autoRequestPermission: false, // Test manual permission flow
showForegroundNotifications: false, // Test background-only mode
);
```

## Next Steps

Once you've verified the SDK works correctly with this example:

1. Integrate the SDK into your actual app
2. Test in production environment
3. Publish the SDK to pub.dev
4. Update your app to use the published version
28 changes: 28 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
17 changes: 17 additions & 0 deletions example/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
.cxx/

# Remember to never publicly share your keystore.
# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks

# Firebase
google-services.json
Loading