Skip to content

Commit

Permalink
Release prep (#176)
Browse files Browse the repository at this point in the history
* Update readme & changelog

# Conflicts:
#	CHANGELOG.md

* Update methods

* Updates

* Update CHANGELOG.md
  • Loading branch information
rlepinski authored Aug 21, 2023
1 parent e30231d commit db55a10
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 307 deletions.
21 changes: 19 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
# Flutter Plugin Changelog

## Version 7.0.0 - August 15, 2023
TODO
## Version 7.0.0 - August 21, 2023
Major release that exposes significantly more of the underlying SDK functionality to Flutter. This release has several breaking changes due to the new modular APIs. Apps should use the migration guide to update [Migration Guide](https://github.com/urbanairship/airship-flutter/blob/main/MIGRATION.md).

### Behavior Changes
- The default Message Center UI will now display unless disabled by `Airship.messageCenter.setAutoLaunchDefaultMessageCenter(false);`
- Apps must now disable the default preference center UI per preference center ID.

### Changes
- Updated to Android SDK 17.1.0 and iOS SDK 17.1.2
- Added feature flag support
- Added new flutter takeOff method with full config support
- Added new methods to control notification options on iOS
- Added new listeners for notification status, push token, and iOS authorized settings
- Added methods to override locale used by Airship messaging
- Added actions component to manually run any actions from the action's framework
- Added method to control the In-App display interval
- Fixed subscription list scope parsing
- Fixed dropping custom events with null values
- Dropped `intl` dependency

## Version 6.3.2 - May 19, 2023
Patch release that updates the intl package dependency to support versions `>=0.15.7 <1.0.0`.
Expand Down
154 changes: 61 additions & 93 deletions MIGRATION.md

Large diffs are not rendered by default.

205 changes: 7 additions & 198 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,202 +1,11 @@
# Airship Plugin
# Airship Flutter

The Airship Flutter plugin allows using Airship's native iOS and Android APIs with Flutter apps written in Dart.
A Flutter plugin for Airship's iOS and Android SDK.

## Usage
### Resources
* [Getting started guide](https://docs.airship.com/platform/mobile/setup/sdk/flutter//)
* [API docs](https://docs.airship.com/reference/libraries/react-native/latest/)

1. Add the airship_flutter dependency to your package's pubspec.yaml file:
### Issues

```yaml
dependencies:
airship_flutter: ^7.0.0
```
2. Install your flutter package dependencies by running the following in the command line at your project's root directory:
```sh
$ flutter pub get
```

3. Import airship into your project:

```dart
import 'package:airship_flutter/airship_flutter.dart';
```

### Android Setup

1) Download the Firebase google-services.json file and place it inside android/app.

2) Apply the `com.google.gms.google-services` plugin to the android/app.

3) Create a new `airshipconfig.properties` file with your application’s settings and
place it inside the `android/app/src/main/assets` directory:

```properties
developmentAppKey = Your Development App Key
developmentAppSecret = Your Development App Secret

productionAppKey = Your Production App Key
productionAppSecret = Your Production Secret

# Toggles between the development and production app credentials
# Before submitting your application to an app store set to true
inProduction = false

# LogLevel is "VERBOSE", "DEBUG", "INFO", "WARN", "ERROR" or "ASSERT"
developmentLogLevel = DEBUG
productionLogLevel = ERROR

# Notification customization
notificationIcon = ic_notification
notificationAccentColor = #ff0000

# Optional - Set the default channel
notificationChannel = customChannel
```

4) Optional. In order to be notified of messages that are sent to the device while the app is in the background,
define a `BackgroundMessageHandler` as a top-level function in your app's main.dart file:

```dart
Future<void> backgroundMessageHandler(
Map<String, dynamic> payload,
Notification? notification) async {
// Handle the message
print("Received background message: $payload, $notification");
}
void main() {
Airship.setBackgroundMessageHandler(backgroundMessageHandler);
runApp(MyApp());
}
```

The handler is executed in a separate background isolate outside the application's main isolate,
so it is not possible to interact with the application UI or update application state from the handler.
Care should be taken to ensure the handler logic completes as soon as possible in order to avoid
ANRs (Application Not Responding), which may trigger the OS to automatically terminate the process.

####EU Cloud Site
If your app uses Airship’s EU cloud site, you will need to add that to `airshipconfig.properties`. By default, the Airship SDK will use the `US` cloud site.

```
# EU Cloud Site
site = EU
```

### iOS Setup

1) Add the following capabilities for your application target:
- Push Notification
- Background Modes > Remote Notifications

2) Create a plist `AirshipConfig.plist` and include it in your application’s target:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>developmentAppKey</key>
<string>Your Development App Key</string>
<key>developmentAppSecret</key>
<string>Your Development App Secret</string>
<key>productionAppKey</key>
<string>Your Production App Key</string>
<key>productionAppSecret</key>
<string>Your Production App Secret</string>
</dict>
</plist>
```

3) Optional. In order to take advantage of iOS 10 notification attachments, such as images, animated gifs, and
video, you will need to create a notification service extension by following the [iOS Notification Service Extension Guide](https://docs.urbanairship.com/platform/reference/ios-extension/)

####EU Cloud Site
If your app uses Airship’s EU cloud site, you will need to add that to `AirshipConfig.plist`. By default, the Airship SDK will use the `US` cloud site.
```
<key>site</key>
<string>EU</string>
```


### Example Usage

```dart
// Import package
import 'package:airship_flutter/airship.dart';
// Tags
Airship.addTags(["flutter"]);
Airship.removeTags(["some-tag"]);
List<String> tags = await Airship.tags;
// Channel ID
String channelId = await Airship.channelId;
// Enable notifications (prompts on iOS)
Airship.setUserNotificationsEnabled(true);
// Events
Airship.onPushReceived
.listen((event) => debugPrint('Push Received $event'));
Airship.onNotificationResponse
.listen((event) => debugPrint('Notification Response $event'));
Airship.onChannelRegistration
.listen((event) => debugPrint('Channel Registration $event'));
Airship.onDeepLink
.listen((deepLink) => debugPrint('Deep link: $deeplink'));
```


### Message Center

Message Center support relies on Flutter's mechanism for embedding Android and iOS views.
Note that Hybrid Composition can be enabled on Android by setting InboxMessageView.hybridComposition to true.

#### Example Usage

```dart
// Import package
import 'package:airship_flutter/airship.dart';
// Messages
List<InboxMessage> messages = await Airship.inboxMessages;
// Delete
Airship.deleteInboxMessage(messages[0]);
// Read
Airship.markInboxMessageRead(messages[0]);
// Events
Airship.onInboxUpdated
.listen((event) => debugPrint('Inbox updated'));
Airship.onShowInbox
.listen((event) => debugPrint('Navigate to app's inbox'));
Airship.onShowInboxMessage
.listen((messageId) => debugPrint('Navigate to message $messageId'));
InboxMessage message = messages[0];
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Message: $message.title'),
),
body: Container(
child: InboxMessageView(messageId: message.messageId),
height: 300.0,
)
)
);
}
```
Please visit https://support.airship.com/ for any issues integrating or using this module.
1 change: 1 addition & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void main() {
]);
Airship.contact.identify("FlutterUser");

Airship.messageCenter.setAutoLaunchDefaultMessageCenter(false);
runApp(MyApp());
}

Expand Down
2 changes: 1 addition & 1 deletion example/lib/screens/message_center.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class _MessageCenterState extends State<MessageCenter> {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("Message \"${message.messageId}\" removed")));
messages.remove(message);
Airship.messageCenter.deleteMessage(message);
Airship.messageCenter.deleteMessage(message.messageId);
setState(() {});
},
// Add stream to check isRead
Expand Down
2 changes: 1 addition & 1 deletion example/lib/screens/preference_center.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class _PreferenceCenterState extends State<PreferenceCenter>

// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initAirshipListeners() async {
Airship.preferenceCenter.onDisplayPreferenceCenter.listen((event) {});
Airship.preferenceCenter.onDisplay.listen((event) {});

Airship.push.onNotificationStatusChanged.listen((event) {
setState(() { isOptedInToNotifications = event.status.isOptedIn; });
Expand Down
19 changes: 10 additions & 9 deletions lib/src/airship_message_center.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class AirshipMessageCenter {
}).toList();
}

/// Marks an inbox [message] as read.
Future<void> markRead(InboxMessage message) async {
/// Marks an inbox message with the [messageId] as read.
Future<void> markRead(String messageId) async {
return await _module.channel.invokeMethod(
'messageCenter#markMessageRead', message.messageId);
'messageCenter#markMessageRead', messageId);
}

/// Requests to display the Message Center.
Expand All @@ -29,10 +29,10 @@ class AirshipMessageCenter {
'messageCenter#display', messageId);
}

/// Deletes an inbox [message].
Future<void> deleteMessage(InboxMessage message) async {
/// Deletes an inbox message with the id [messageId].
Future<void> deleteMessage(String messageId) async {
return await _module.channel.invokeMethod(
'messageCenter#deleteMessage', message.messageId);
'messageCenter#deleteMessage', messageId);
}

/// Gets the unread count.
Expand All @@ -41,8 +41,8 @@ class AirshipMessageCenter {
'messageCenter#getUnreadMessageCount');
}

/// Enables or disables showing the OOTB UI when requested to display
Future<void> setAutoLaunch(bool enabled) async {
/// Enables or disables showing the OOTB UI when requested to display.
Future<void> setAutoLaunchDefaultMessageCenter(bool enabled) async {
return await _module.channel.invokeMethod(
'messageCenter#setAutoLaunch', enabled);
}
Expand All @@ -63,7 +63,8 @@ class AirshipMessageCenter {

}

/// Gets show inbox event stream.
/// Gets show inbox event stream. Events will only be
/// emitted if [setAutoLaunchDefaultMessageCenter] is disabled.
Stream<DisplayMessageCenterEvent> get onDisplay {
return _module
.getEventStream("com.airship.flutter/event/display_message_center")
Expand Down
6 changes: 3 additions & 3 deletions lib/src/airship_preference_center.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ class AirshipPreferenceCenter {
/// Enables or disables auto launching the Preference Center with the given [preferenceCenterID].
/// If auto launch is enabled, Airship will show an OOTB UI for the given preference center ID. If
/// disabled, a display preference center event will be emitted.
Future<void> setAutoLaunchPreferenceCenter(String preferenceCenterID, bool autoLaunch) async {
Future<void> setAutoLaunchDefaultPreferenceCenter(String preferenceCenterID, bool autoLaunch) async {
return await _module.channel.invokeMethod('preferenceCenter#setAutoLaunch', [preferenceCenterID, autoLaunch]);
}

/// Opens the Preference Center with the given [preferenceCenterID].
Future<void> openPreferenceCenter(String preferenceCenterID) async {
Future<void> display(String preferenceCenterID) async {
return await _module.channel.invokeMethod(
'preferenceCenter#display', preferenceCenterID);
}

/// Gets show preference center event stream.
Stream<DisplayPreferenceCenterEvent> get onDisplayPreferenceCenter {
Stream<DisplayPreferenceCenterEvent> get onDisplay {
return _module.getEventStream("com.airship.flutter/event/display_preference_center")
.map((dynamic value) => DisplayPreferenceCenterEvent.fromJson(value));
}
Expand Down

0 comments on commit db55a10

Please sign in to comment.