Skip to content

Commit d9363d3

Browse files
authored
Merge pull request #2988 from StoDevX/push-notifications-settings-hawken
Add Push Notifications settings
2 parents f84ed7a + c6879bf commit d9363d3

File tree

24 files changed

+753
-35
lines changed

24 files changed

+753
-35
lines changed

android/app/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ android {
113113
manifestPlaceholders = [
114114
manifestApplicationId: applicationId,
115115
BUGSNAG_KEY: System.getenv("BUGSNAG_KEY") ?: "",
116-
onesignal_app_id: "a46c6f2f-a240-4908-a359-801911e9b9ea",
117116
onesignal_google_project_number: "REMOTE",
118117
]
119118

fastlane/platforms/ios.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
language: 'English',
147147
enable_services: {
148148
push_notification: 'on',
149+
app_group: 'on',
149150
},
150151
)
151152

@@ -156,6 +157,7 @@
156157
skip_itc: 'on',
157158
enable_services: {
158159
push_notification: 'off',
160+
app_group: 'on',
159161
},
160162
)
161163
end
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
// flow-typed signature: 711d38edadc6dba0fec911b42c30753d
2+
// flow-typed version: <<STUB>>/react-native-onesignal_v3.1.4/flow_v0.67.1
3+
4+
/**
5+
* This is an autogenerated libdef stub for:
6+
*
7+
* 'react-native-onesignal'
8+
*
9+
* Fill this stub out by replacing all the `any` types.
10+
*
11+
* Once filled out, we encourage you to share your work with the
12+
* community by sending a pull request to:
13+
* https://github.com/flowtype/flow-typed
14+
*/
15+
16+
declare module 'react-native-onesignal' {
17+
declare export type OneSignalOpenResult = {
18+
notification: {
19+
payload: {
20+
body: any,
21+
additionalData: any,
22+
},
23+
isAppInFocus: boolean,
24+
},
25+
}
26+
27+
declare export type OneSignalNotification = {
28+
shown: boolean,
29+
payload: {
30+
notificationID: '',
31+
contentAvailable: boolean,
32+
badge: 1,
33+
sound: 'default',
34+
title: 'Hello!',
35+
body: 'World',
36+
launchURL: '',
37+
},
38+
displayType: 1,
39+
silentNotification: boolean,
40+
}
41+
42+
declare export type OneSignalIdsResult = {
43+
pushToken: ?string,
44+
subscribed: boolean,
45+
userId: ?string,
46+
userSubscriptionSetting: boolean,
47+
}
48+
49+
declare type EventTypeEnum = 'received' | 'opened' | 'ids' | 'emailSubscription';
50+
51+
declare type Permissions = {
52+
alert: boolean,
53+
badge: boolean,
54+
sound: boolean,
55+
}
56+
57+
declare export type SubscriptionState = {
58+
hasPrompted: boolean,
59+
notificationsEnabled: boolean,
60+
subscriptionEnabled: boolean,
61+
userSubscriptionEnabled: boolean,
62+
pushToken: ?string,
63+
userId: ?string,
64+
emailUserId: ?string,
65+
emailAddress: ?string,
66+
emailSubscribed: boolean
67+
};
68+
69+
declare export type TagsObject = {[key: string]: string}
70+
71+
declare type DisplayOption =
72+
| 0 // None
73+
| 1 // InAppAlert
74+
| 2 // Notification
75+
76+
declare export type NotificationContent = {}
77+
declare export type NotificationData = {}
78+
declare export type NotificationParameters = {hidden?: boolean}
79+
80+
declare export type IosSettings = {
81+
kOSSettingsKeyAutoPrompt?: boolean,
82+
kOSSettingsKeyInAppLaunchURL?: boolean,
83+
kOSSSettingsKeyPromptBeforeOpeningPushURL?: boolean,
84+
kOSSettingsKeyInFocusDisplayOption?: DisplayOption,
85+
};
86+
87+
declare export default class OneSignal {
88+
static addEventListener(type: 'received', handler: (OneSignalNotification) => mixed): void;
89+
static addEventListener(type: 'opened', handler: (OneSignalOpenResult) => mixed): void;
90+
static addEventListener(type: 'ids', handler: (OneSignalIdsResult) => mixed): void;
91+
static addEventListener(type: 'emailSubscription', handler: (...any[]) => mixed): void;
92+
static removeEventListener(type: EventTypeEnum, handler: Function): void;
93+
static clearListeners(): void;
94+
95+
static registerForPushNotifications(): void;
96+
97+
static promptForPushNotificationsWithUserResponse(callback: (bool) => mixed): void;
98+
99+
static requestPermissions(permissions: Permissions): void;
100+
101+
static configure(): void;
102+
103+
static init(appId: string, iosSettings: IosSettings): void;
104+
105+
static checkPermissions(callback: (Permissions) => mixed): void;
106+
107+
static promptForPushNotificationPermissions(callback: (bool) => mixed): void;
108+
109+
static getPermissionSubscriptionState(callback: (SubscriptionState) => mixed): void;
110+
111+
static sendTag(key: string, value: string): void;
112+
static sendTags(TagsObject): void;
113+
static getTags((null | TagsObject | Error) => mixed): void;
114+
static deleteTag(key: string): void;
115+
116+
static enableVibrate(enable: boolean): void;
117+
static enableSound(enable: boolean): void;
118+
119+
static setEmail(email: string): void;
120+
static setEmail(email: string, emailAuthCode: string): void;
121+
static setEmail(email: string, callback: (?Error) => mixed): void;
122+
static setEmail(email: string, emailAuthCode: string, callback: (?Error) => mixed): void;
123+
124+
static logoutEmail(callback: (?Error) => mixed): void;
125+
126+
static setLocationShared(enable: boolean): void;
127+
static setSubscription(enable: boolean): void;
128+
129+
static promptLocation(): void;
130+
131+
static inFocusDisplaying(DisplayOption): void;
132+
133+
static postNotification(contents: NotificationContent, data: NotificationData, player_id: string | Array<string>): void;
134+
static postNotification(contents: NotificationContent, data: NotificationData, player_id: string | Array<string>, otherParameters?: NotificationParameters): void;
135+
136+
static clearOneSignalNotifications(): void;
137+
static cancelNotification(id: number): void;
138+
139+
static syncHashedEmail(email: string): void;
140+
141+
static setLogLevel(level: string): void;
142+
143+
static setRequiresUserPrivacyConsent(required: boolean): void;
144+
static provideUserConsent(granted: boolean): void;
145+
static userProvidedPrivacyConsent(): Promise<boolean>;
146+
}
147+
}

ios/AllAboutOlaf.xcodeproj/project.pbxproj

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
4343
146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
4444
23787DFEFF9747949AE97A42 /* Ionicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = E6FBE71A05CC43E2B4885180 /* Ionicons.ttf */; };
45-
2D2C03E9364242759337907D /* libRCTOneSignal.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 768B9C2ACFD14FD7BDAD0025 /* libRCTOneSignal.a */; };
4645
3A0CEA921DEA203F0036E739 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A0CEA781DEA20340036E739 /* libRCTAnimation.a */; };
46+
3AD99DE32141CA1600D8CAAA /* libRCTOneSignal.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D18853A920995CEB000A1DC5 /* libRCTOneSignal.a */; };
4747
3AE408501E1E280800F0FD83 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3AE4084F1E1E280800F0FD83 /* LaunchScreen.storyboard */; };
4848
679C3A672050B38F00B4D498 /* libRCTMGL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 679C3A662050B37200B4D498 /* libRCTMGL.a */; };
4949
679C3A6E2050B4F100B4D498 /* Mapbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 679C3A6D2050B4F100B4D498 /* Mapbox.framework */; };
@@ -530,11 +530,11 @@
530530
43E420DADB24468C9E296F25 /* RNVectorIcons.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNVectorIcons.xcodeproj; path = "../node_modules/react-native-vector-icons/RNVectorIcons.xcodeproj"; sourceTree = "<group>"; };
531531
4E4DA38580594A71BEE6DAB5 /* RNSearchBar.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNSearchBar.xcodeproj; path = "../node_modules/react-native-search-bar/ios/RNSearchBar.xcodeproj"; sourceTree = "<group>"; };
532532
59C781128E0B476A8826CD12 /* BugsnagReactNative.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = BugsnagReactNative.xcodeproj; path = "../node_modules/bugsnag-react-native/cocoa/BugsnagReactNative.xcodeproj"; sourceTree = "<group>"; };
533+
6787664D213C7E7E00E33DFF /* OneSignalNotificationServiceExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OneSignalNotificationServiceExtension.entitlements; sourceTree = "<group>"; };
533534
679C3A6D2050B4F100B4D498 /* Mapbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Mapbox.framework; path = "../node_modules/@mapbox/react-native-mapbox-gl/ios/Mapbox.framework"; sourceTree = "<group>"; };
534535
67A1EEA72072C1340059399D /* RNDeviceInfo.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNDeviceInfo.xcodeproj; path = "../node_modules/react-native-device-info/ios/RNDeviceInfo.xcodeproj"; sourceTree = "<group>"; };
535536
71D5CCADA66D45008D9A38F2 /* RNVectorIcons.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNVectorIcons.xcodeproj; path = "../node_modules/react-native-vector-icons/RNVectorIcons.xcodeproj"; sourceTree = "<group>"; };
536537
742B362B86E443C09A7F9FD9 /* Entypo.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Entypo.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Entypo.ttf"; sourceTree = "<group>"; };
537-
768B9C2ACFD14FD7BDAD0025 /* libRCTOneSignal.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRCTOneSignal.a; sourceTree = "<group>"; };
538538
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
539539
7CEE763ECB05435E8CD79870 /* RNNetworkInfo.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNNetworkInfo.xcodeproj; path = "../node_modules/react-native-network-info/ios/RNNetworkInfo.xcodeproj"; sourceTree = "<group>"; };
540540
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
@@ -598,7 +598,7 @@
598598
00958A8F2008726000073F2F /* libRNSearchBar.a in Frameworks */,
599599
679C3A672050B38F00B4D498 /* libRCTMGL.a in Frameworks */,
600600
67A1EEB02072C1860059399D /* libRNDeviceInfo.a in Frameworks */,
601-
2D2C03E9364242759337907D /* libRCTOneSignal.a in Frameworks */,
601+
3AD99DE32141CA1600D8CAAA /* libRCTOneSignal.a in Frameworks */,
602602
);
603603
runOnlyForDeploymentPostprocessing = 0;
604604
};
@@ -971,7 +971,6 @@
971971
83CBBA001A601CBA00E9B192 /* Products */,
972972
5A41494DACBB4D2795B46DE0 /* Resources */,
973973
3C5BFA21338636E7EB4E5E0D /* Frameworks */,
974-
D188536D20995CEA000A1DC5 /* Recovered References */,
975974
);
976975
indentWidth = 2;
977976
sourceTree = "<group>";
@@ -987,14 +986,6 @@
987986
name = Products;
988987
sourceTree = "<group>";
989988
};
990-
D188536D20995CEA000A1DC5 /* Recovered References */ = {
991-
isa = PBXGroup;
992-
children = (
993-
768B9C2ACFD14FD7BDAD0025 /* libRCTOneSignal.a */,
994-
);
995-
name = "Recovered References";
996-
sourceTree = "<group>";
997-
};
998989
D18853A520995CEB000A1DC5 /* Products */ = {
999990
isa = PBXGroup;
1000991
children = (
@@ -1006,6 +997,7 @@
1006997
D1FC244D209B6EDF002CD083 /* OneSignalNotificationServiceExtension */ = {
1007998
isa = PBXGroup;
1008999
children = (
1000+
6787664D213C7E7E00E33DFF /* OneSignalNotificationServiceExtension.entitlements */,
10091001
D1FC244E209B6EDF002CD083 /* NotificationService.h */,
10101002
D1FC244F209B6EDF002CD083 /* NotificationService.m */,
10111003
D1FC2451209B6EDF002CD083 /* Info.plist */,
@@ -1095,7 +1087,7 @@
10951087
ProvisioningStyle = Manual;
10961088
SystemCapabilities = {
10971089
com.apple.ApplicationGroups.iOS = {
1098-
enabled = 0;
1090+
enabled = 1;
10991091
};
11001092
com.apple.BackgroundModes = {
11011093
enabled = 1;
@@ -1109,6 +1101,11 @@
11091101
CreatedOnToolsVersion = 9.3;
11101102
DevelopmentTeam = TMK6S7TPX2;
11111103
ProvisioningStyle = Manual;
1104+
SystemCapabilities = {
1105+
com.apple.ApplicationGroups.iOS = {
1106+
enabled = 1;
1107+
};
1108+
};
11121109
};
11131110
};
11141111
};
@@ -2041,14 +2038,14 @@
20412038
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
20422039
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
20432040
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
2041+
CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements;
20442042
CODE_SIGN_IDENTITY = "iPhone Developer";
20452043
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
20462044
CODE_SIGN_STYLE = Manual;
20472045
DEBUG_INFORMATION_FORMAT = dwarf;
20482046
DEVELOPMENT_TEAM = TMK6S7TPX2;
20492047
GCC_C_LANGUAGE_STANDARD = gnu11;
20502048
INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist;
2051-
IPHONEOS_DEPLOYMENT_TARGET = 11.3;
20522049
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
20532050
PRODUCT_BUNDLE_IDENTIFIER = "NFMTHAZVS9.com.drewvolz.stolaf.onesignal-notification-service-extension";
20542051
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -2070,6 +2067,7 @@
20702067
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
20712068
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
20722069
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
2070+
CODE_SIGN_ENTITLEMENTS = OneSignalNotificationServiceExtension/OneSignalNotificationServiceExtension.entitlements;
20732071
CODE_SIGN_IDENTITY = "iPhone Developer";
20742072
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
20752073
CODE_SIGN_STYLE = Manual;
@@ -2078,7 +2076,6 @@
20782076
DEVELOPMENT_TEAM = TMK6S7TPX2;
20792077
GCC_C_LANGUAGE_STANDARD = gnu11;
20802078
INFOPLIST_FILE = OneSignalNotificationServiceExtension/Info.plist;
2081-
IPHONEOS_DEPLOYMENT_TARGET = 11.3;
20822079
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
20832080
PRODUCT_BUNDLE_IDENTIFIER = "NFMTHAZVS9.com.drewvolz.stolaf.onesignal-notification-service-extension";
20842081
PRODUCT_NAME = "$(TARGET_NAME)";

ios/AllAboutOlaf/AllAboutOlaf.entitlements

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@
44
<dict>
55
<key>aps-environment</key>
66
<string>development</string>
7+
<key>com.apple.security.application-groups</key>
8+
<array>
9+
<string>group.NFMTHAZVS9.com.drewvolz.stolaf.onesignal</string>
10+
</array>
711
</dict>
812
</plist>

ios/AllAboutOlaf/AppDelegate.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
5454
// ignore vibrate/silent switch when playing audio
5555
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil];
5656

57-
self.oneSignal = [[RCTOneSignal alloc] initWithLaunchOptions:launchOptions
58-
appId:@"a46c6f2f-a240-4908-a359-801911e9b9ea"];
5957
return YES;
6058
}
6159

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.application-groups</key>
6+
<array>
7+
<string>group.NFMTHAZVS9.com.drewvolz.stolaf.onesignal</string>
8+
</array>
9+
</dict>
10+
</plist>

modules/analytics/google-analytics.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,21 @@ export const trackLoginFailure = (reason: string) =>
8181
tracker.trackEvent('account', 'login-failure', {label: reason, value: 1})
8282

8383
export const trackLogOut = () => tracker.trackEvent('account', 'log-out')
84+
85+
export const trackChannelSubscribe = (channelName: string) =>
86+
tracker.trackEvent('notification-channel', 'subscribe', {
87+
label: channelName,
88+
value: 1,
89+
})
90+
91+
export const trackChannelUnsubscribe = (streamName: string) =>
92+
tracker.trackEvent('notification-channel', 'unsubscribe', {
93+
label: streamName,
94+
value: 1,
95+
})
96+
97+
export const trackNotificationsDisable = () =>
98+
tracker.trackEvent('notification-channel', 'disabled')
99+
100+
export const trackNotificationsEnable = () =>
101+
tracker.trackEvent('notifications', 'enabled')

modules/tableview/cells/toggle.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,31 @@ type PropsType = {
1010
value: boolean,
1111
onChange: (val: boolean) => any,
1212
theme: AppTheme,
13+
detail?: string,
14+
disabled?: boolean,
1315
}
1416

15-
function CellToggle({value, onChange, label, theme}: PropsType) {
17+
function CellToggle(props: PropsType) {
18+
let {value, onChange, label, detail, theme, disabled} = props
19+
1620
let toggle = (
1721
<Switch
22+
disabled={disabled}
1823
onTintColor={theme.switchTintOn}
1924
onValueChange={onChange}
2025
tintColor={theme.switchTintOff}
2126
value={value}
2227
/>
2328
)
2429

25-
return <Cell cellAccessoryView={toggle} title={label} />
30+
return (
31+
<Cell
32+
cellAccessoryView={toggle}
33+
cellStyle={detail ? 'Subtitle' : 'Basic'}
34+
detail={detail}
35+
title={label}
36+
/>
37+
)
2638
}
2739

2840
export const RawCellToggle = CellToggle

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
"react-native-keychain": "3.0.0",
129129
"react-native-linear-gradient": "2.4.2",
130130
"react-native-network-info": "4.0.0",
131-
"react-native-onesignal": "3.1.4",
131+
"react-native-onesignal": "3.2.6",
132132
"react-native-popover-view": "1.0.8",
133133
"react-native-restart": "0.0.7",
134134
"react-native-safari-view": "2.1.0",

0 commit comments

Comments
 (0)