Skip to content
Open
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
2 changes: 1 addition & 1 deletion android/src/main/java/com/mindboxsdk/MindboxSdkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class MindboxSdkModule(private val reactContext: ReactApplicationContext) : Reac
}

@ReactMethod
fun updateNotificationPermissionStatus(granted: Boolean) {
fun refreshNotificationPermissionStatus() {
Mindbox.updateNotificationPermissionStatus(
context = reactApplicationContext.applicationContext,
)
Expand Down
2 changes: 1 addition & 1 deletion example/exampleApp/ios/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
extension AppDelegate: RCTBridgeDelegate {
func sourceURL(for bridge: RCTBridge!) -> URL! {
#if DEBUG
return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index", fallbackResource: nil)
return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
return Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
Expand Down
41 changes: 23 additions & 18 deletions example/exampleApp/ios/exampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
3ACCD5252B736C0000C94F45 /* UserNotificationsUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3ACCD5242B736C0000C94F45 /* UserNotificationsUI.framework */; };
3ACCD5282B736C0000C94F45 /* NotificationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3ACCD5272B736C0000C94F45 /* NotificationViewController.swift */; };
3ACCD52F2B736C0000C94F45 /* MindboxNotificationContentExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 3ACCD5212B736C0000C94F45 /* MindboxNotificationContentExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
47632DE92EBB68C1005CF203 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 47632DE82EBB68C1005CF203 /* PrivacyInfo.xcprivacy */; };
6FA2F0A6E649B5D37A50E5DF /* libPods-exampleApp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 225AB1FB2853D87400D56406 /* libPods-exampleApp.a */; };
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
D12DD691CE76549C9A289F4A /* libPods-exampleApp-MindboxNotificationContentExtension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F94D0E16F83CA4229F8935E5 /* libPods-exampleApp-MindboxNotificationContentExtension.a */; };
Expand Down Expand Up @@ -85,6 +86,7 @@
3ACCD5332B736C3600C94F45 /* MindboxNotificationContentExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MindboxNotificationContentExtension.entitlements; sourceTree = "<group>"; };
443E0C92268BE125C44414DB /* Pods-exampleApp-MindboxNotificationServiceExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-exampleApp-MindboxNotificationServiceExtension.debug.xcconfig"; path = "Target Support Files/Pods-exampleApp-MindboxNotificationServiceExtension/Pods-exampleApp-MindboxNotificationServiceExtension.debug.xcconfig"; sourceTree = "<group>"; };
47152D5D7BA14904B8BB519A /* Pods-exampleApp-MindboxNotificationContentExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-exampleApp-MindboxNotificationContentExtension.release.xcconfig"; path = "Target Support Files/Pods-exampleApp-MindboxNotificationContentExtension/Pods-exampleApp-MindboxNotificationContentExtension.release.xcconfig"; sourceTree = "<group>"; };
47632DE82EBB68C1005CF203 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = exampleApp/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
47AD8F18AB85B027D3981AE3 /* Pods-exampleApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-exampleApp.debug.xcconfig"; path = "Target Support Files/Pods-exampleApp/Pods-exampleApp.debug.xcconfig"; sourceTree = "<group>"; };
52276FFC6E12FB80FA062002 /* libPods-exampleApp-exampleAppTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-exampleApp-exampleAppTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
6A5E00695C40D3AAF012A013 /* Pods-exampleApp-MindboxNotificationContentExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-exampleApp-MindboxNotificationContentExtension.debug.xcconfig"; path = "Target Support Files/Pods-exampleApp-MindboxNotificationContentExtension/Pods-exampleApp-MindboxNotificationContentExtension.debug.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -130,6 +132,7 @@
13B07FAE1A68108700A75B9A /* exampleApp */ = {
isa = PBXGroup;
children = (
47632DE82EBB68C1005CF203 /* PrivacyInfo.xcprivacy */,
3A88FC0B2B6CEE180046E687 /* exampleApp.entitlements */,
13B07FB51A68108700A75B9A /* Images.xcassets */,
13B07FB61A68108700A75B9A /* Info.plist */,
Expand Down Expand Up @@ -348,6 +351,7 @@
buildActionMask = 2147483647;
files = (
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
47632DE92EBB68C1005CF203 /* PrivacyInfo.xcprivacy in Resources */,
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -393,14 +397,10 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-exampleApp/Pods-exampleApp-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-exampleApp/Pods-exampleApp-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-exampleApp/Pods-exampleApp-frameworks.sh\"\n";
Expand All @@ -414,14 +414,10 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-exampleApp/Pods-exampleApp-resources-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-exampleApp/Pods-exampleApp-resources-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-exampleApp/Pods-exampleApp-resources.sh\"\n";
Expand All @@ -435,14 +431,10 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-exampleApp-MindboxNotificationContentExtension/Pods-exampleApp-MindboxNotificationContentExtension-resources-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-exampleApp-MindboxNotificationContentExtension/Pods-exampleApp-MindboxNotificationContentExtension-resources-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-exampleApp-MindboxNotificationContentExtension/Pods-exampleApp-MindboxNotificationContentExtension-resources.sh\"\n";
Expand Down Expand Up @@ -500,14 +492,10 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-exampleApp-MindboxNotificationServiceExtension/Pods-exampleApp-MindboxNotificationServiceExtension-resources-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-exampleApp-MindboxNotificationServiceExtension/Pods-exampleApp-MindboxNotificationServiceExtension-resources-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-exampleApp-MindboxNotificationServiceExtension/Pods-exampleApp-MindboxNotificationServiceExtension-resources.sh\"\n";
Expand Down Expand Up @@ -610,6 +598,7 @@
PRODUCT_BUNDLE_IDENTIFIER = mindbox.RN.Example;
PRODUCT_NAME = exampleApp;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OBJC_BRIDGING_HEADER = "exampleApp-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -643,6 +632,7 @@
PRODUCT_BUNDLE_IDENTIFIER = mindbox.RN.Example;
PRODUCT_NAME = exampleApp;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
SWIFT_OBJC_BRIDGING_HEADER = "exampleApp-Bridging-Header.h";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
Expand Down Expand Up @@ -833,6 +823,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = "$(inherited)";
CC = "";
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "c++20";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -860,6 +851,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CXX = "";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
Expand All @@ -879,6 +871,8 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
LD = "";
LDPLUSPLUS = "";
LD_RUNPATH_SEARCH_PATHS = (
/usr/lib/swift,
"$(inherited)",
Expand All @@ -898,9 +892,13 @@
"-DFOLLY_USE_LIBCPP=1",
"-DFOLLY_CFG_NO_COROUTINES=1",
);
OTHER_LDFLAGS = "$(inherited) ";
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
USE_HERMES = true;
};
name = Debug;
Expand All @@ -909,6 +907,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = "$(inherited)";
CC = "";
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "c++20";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -936,6 +935,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
CXX = "";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
Expand All @@ -948,6 +948,8 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
LD = "";
LDPLUSPLUS = "";
LD_RUNPATH_SEARCH_PATHS = (
/usr/lib/swift,
"$(inherited)",
Expand All @@ -966,7 +968,10 @@
"-DFOLLY_USE_LIBCPP=1",
"-DFOLLY_CFG_NO_COROUTINES=1",
);
OTHER_LDFLAGS = "$(inherited) ";
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = true;
Expand Down
48 changes: 48 additions & 0 deletions example/exampleApp/ios/exampleApp/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyTrackingDomains</key>
<array/>
<key>NSPrivacyCollectedDataTypes</key>
<array>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeOtherDiagnosticData</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeDeviceID</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<true/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeProductPersonalization</string>
</array>
</dict>
</array>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
</array>
</dict>
</array>
</dict>
</plist>
27 changes: 18 additions & 9 deletions example/exampleApp/src/screens/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { chooseInappCallback, RegisterInappCallback } from '../utils/InAppCallba
const configuration = {
domain: 'api.mindbox.ru',
// Set your endpoints system name for ios and android below
endpointId: Platform.OS === 'ios' ? '' : '',
endpointId: Platform.OS === 'ios' ? 'Mpush-test.IosRnExample' : 'Mpush-test.AndroidRnExample',
subscribeCustomerIfCreated: true,
shouldCreateCustomer: true,
}
Expand All @@ -26,18 +26,27 @@ const HomeScreen = () => {
const [sdkVersion, setSdkVersion] = useState('Empty')

useEffect(() => {
requestNotificationPermission()
appInitializationCallback()
// https://developers.mindbox.ru/docs/%D0%BC%D0%B5%D1%82%D0%BE%D0%B4%D1%8B-react-natice-sdk#setloglevel-since-280
MindboxSdk.setLogLevel(LogLevel.DEBUG)

requestNotificationPermission()
appInitializationCallback()

// https://developers.mindbox.ru/docs/%D0%BC%D0%B5%D1%82%D0%BE%D0%B4%D1%8B-react-natice-sdk#getdeviceuuid
MindboxSdk.getDeviceUUID(setDeviceUUID)
// https://developers.mindbox.ru/docs/%D0%BC%D0%B5%D1%82%D0%BE%D0%B4%D1%8B-react-natice-sdk#gettoken
MindboxSdk.getTokens(setToken)
// https://developers.mindbox.ru/docs/%D0%BC%D0%B5%D1%82%D0%BE%D0%B4%D1%8B-react-natice-sdk#getsdkversion-since-280
MindboxSdk.getSdkVersion((version) => {
setSdkVersion(version)
MindboxSdk.getDeviceUUID((uuid: string) => {
setDeviceUUID(uuid)

// https://developers.mindbox.ru/docs/%D0%BC%D0%B5%D1%82%D0%BE%D0%B4%D1%8B-react-natice-sdk#gettoken
MindboxSdk.getTokens((t: string) => {
setToken(t)

// https://developers.mindbox.ru/docs/%D0%BC%D0%B5%D1%82%D0%BE%D0%B4%D1%8B-react-natice-sdk#getsdkversion-since-280
MindboxSdk.getSdkVersion((version) => {
setSdkVersion(version)
})
})
})

// https://developers.mindbox.ru/docs/in-app#react-native
chooseInappCallback(RegisterInappCallback.DEFAULT)
}, [appInitializationCallback])
Expand Down
8 changes: 1 addition & 7 deletions example/exampleApp/src/utils/RequestPermission.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ import MindboxSdk from 'mindbox-sdk'

export const requestNotificationPermission = async () => {
requestNotifications(['alert', 'sound']).then(({ status, settings }) => {
if (status === RESULTS.GRANTED) {
console.log('Permission granted')
MindboxSdk.updateNotificationPermissionStatus(true)
} else {
console.log('Permission not granted')
MindboxSdk.updateNotificationPermissionStatus(false)
}
MindboxSdk.refreshNotificationPermissionStatus()
})
}
2 changes: 1 addition & 1 deletion ios/MindboxSdk.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ @interface RCT_EXTERN_MODULE(MindboxSdk, NSObject)

RCT_EXTERN_METHOD(pushDelivered:(NSString)uniqKey)

RCT_EXTERN_METHOD(updateNotificationPermissionStatus:(BOOL)granted)
RCT_EXTERN_METHOD(refreshNotificationPermissionStatus)

RCT_EXTERN_METHOD(writeNativeLog:(NSString)message level:(NSInteger)level)

Expand Down
4 changes: 2 additions & 2 deletions ios/MindboxSdk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ class MindboxSdk: NSObject {
}

@objc
func updateNotificationPermissionStatus(_ granted: Bool) {
Mindbox.shared.notificationsRequestAuthorization(granted: granted)
func refreshNotificationPermissionStatus() {
Mindbox.shared.refreshNotificationPermissionStatus()
}

@objc
Expand Down
19 changes: 17 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,27 @@ class MindboxSdkClass {
}

/**
* This method is used to inform sdk when the notification permission status changed
* This method is kept for backward compatibility. The `granted` argument is ignored.
* The SDK reads the current system authorization status and, if it differs
* from the last known value, sends an update to the backend.
*
* @param granted current permission status
* @deprecated Use `refreshNotificationPermissionStatus()` instead.
*/
public updateNotificationPermissionStatus(granted: Boolean) {
return MindboxSdkNative.updateNotificationPermissionStatus(granted)
console.warn(`updateNotificationPermissionStatus(granted=${String(granted)}) is deprecated. Use refreshNotificationPermissionStatus instead.`)
return MindboxSdkNative.refreshNotificationPermissionStatus()
}

/**
* Checks the current system authorization status for push notifications
* and reports any changes to Mindbox.
*
* @example
* MindboxSdk.refreshNotificationPermissionStatus()
*/
public refreshNotificationPermissionStatus() {
return MindboxSdkNative.refreshNotificationPermissionStatus()
}

/**
Expand Down