Skip to content

Commit fa9558a

Browse files
committed
chore(demo): add sound notification support
1 parent a851437 commit fa9558a

7 files changed

Lines changed: 27 additions & 2 deletions

File tree

783 KB
Binary file not shown.

examples/demo/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PODS:
22
- Flutter (1.0.0)
3-
- onesignal_flutter (5.5.0):
3+
- onesignal_flutter (5.5.1):
44
- Flutter
55
- OneSignalXCFramework (= 5.5.0)
66
- OneSignalXCFramework (5.5.0):
@@ -78,7 +78,7 @@ EXTERNAL SOURCES:
7878

7979
SPEC CHECKSUMS:
8080
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
81-
onesignal_flutter: 786a2ae8d69120f3041f0f1de326bee63b319e3e
81+
onesignal_flutter: e2e682f7c4b0604ddba445d4f8ea6e79c77dabe1
8282
OneSignalXCFramework: 943852e7d70d719f73e9669d48620aeec1b93022
8383
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
8484
url_launcher_ios: 7a95fa5b60cc718a708b8f2966718e93db0cef1b

examples/demo/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
DCC74E696EB253DBC854FB79 /* Pods_OneSignalNotificationServiceExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA1153E70A142A707DAB6259 /* Pods_OneSignalNotificationServiceExtension.framework */; };
2525
DDEE00330000000000000002 /* OneSignalNotificationServiceExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = AABB00110000000000000004 /* OneSignalNotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
2626
DDEE00330000000000000003 /* OneSignalWidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = BBCC00220000000000000004 /* OneSignalWidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
27+
CCDD00440000000000000002 /* vine_boom.wav in Resources */ = {isa = PBXBuildFile; fileRef = CCDD00440000000000000001 /* vine_boom.wav */; };
2728
E136047CBA6463056CAFE6AA /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F4C80DF527D85592B0E6C158 /* Pods_RunnerTests.framework */; };
2829
/* End PBXBuildFile section */
2930

@@ -113,6 +114,7 @@
113114
BBCC00220000000000000013 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; };
114115
CCC0329396AC13CCF7D63BE7 /* Pods_OneSignalWidgetExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_OneSignalWidgetExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; };
115116
D46D9E2E67DD813A87D3C230 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
117+
CCDD00440000000000000001 /* vine_boom.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = vine_boom.wav; sourceTree = "<group>"; };
116118
DDEE00330000000000000004 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
117119
DF4FF096C1198FFEEE5E20EA /* Pods-OneSignalNotificationServiceExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalNotificationServiceExtension.debug.xcconfig"; path = "Target Support Files/Pods-OneSignalNotificationServiceExtension/Pods-OneSignalNotificationServiceExtension.debug.xcconfig"; sourceTree = "<group>"; };
118120
ED1A5A3D2AEA3DC7B8B12A7C /* Pods-OneSignalWidgetExtension.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OneSignalWidgetExtension.profile.xcconfig"; path = "Target Support Files/Pods-OneSignalWidgetExtension/Pods-OneSignalWidgetExtension.profile.xcconfig"; sourceTree = "<group>"; };
@@ -247,6 +249,7 @@
247249
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
248250
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
249251
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
252+
CCDD00440000000000000001 /* vine_boom.wav */,
250253
);
251254
path = Runner;
252255
sourceTree = "<group>";
@@ -417,6 +420,7 @@
417420
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
418421
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
419422
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
423+
CCDD00440000000000000002 /* vine_boom.wav in Resources */,
420424
);
421425
runOnlyForDeploymentPostprocessing = 0;
422426
};
783 KB
Binary file not shown.

examples/demo/lib/models/notification_type.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,27 @@ enum NotificationType {
1212
'image':
1313
'https://media.onesignal.com/automated_push_templates/ratings_template.png'
1414
},
15+
),
16+
withSound(
17+
title: 'Sound Notification',
18+
body: 'This notification plays a custom sound',
19+
iosSound: 'vine_boom.wav',
20+
androidChannelId: 'b3b015d9-c050-4042-8548-dcc34aa44aa4',
1521
);
1622

1723
final String title;
1824
final String body;
1925
final String? bigPicture;
2026
final Map<String, String>? iosAttachments;
27+
final String? iosSound;
28+
final String? androidChannelId;
2129

2230
const NotificationType({
2331
required this.title,
2432
required this.body,
2533
this.bigPicture,
2634
this.iosAttachments,
35+
this.iosSound,
36+
this.androidChannelId,
2737
});
2838
}

examples/demo/lib/services/onesignal_api_service.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ class OneSignalApiService {
3333
if (type.iosAttachments != null) {
3434
body['ios_attachments'] = type.iosAttachments;
3535
}
36+
if (type.iosSound != null) {
37+
body['ios_sound'] = type.iosSound;
38+
}
39+
if (type.androidChannelId != null) {
40+
body['android_channel_id'] = type.androidChannelId;
41+
}
3642

3743
final response = await http.post(
3844
Uri.parse('https://onesignal.com/api/v1/notifications'),

examples/demo/lib/widgets/sections/send_push_section.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ class SendPushSection extends StatelessWidget {
3232
onPressed: () => vm.sendNotification(NotificationType.withImage),
3333
),
3434
AppSpacing.gapBox,
35+
PrimaryButton(
36+
label: 'WITH SOUND',
37+
onPressed: () => vm.sendNotification(NotificationType.withSound),
38+
),
39+
AppSpacing.gapBox,
3540
PrimaryButton(
3641
label: 'CUSTOM',
3742
onPressed: () async {

0 commit comments

Comments
 (0)