smartmessage-react-native 2.11.2 → 2.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +21 -0
- package/ios/RNSmartMessage.m +4 -1
- package/ios/RNSmartMessage.swift +72 -6
- package/package.json +1 -1
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 SmartMessage
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/ios/RNSmartMessage.m
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#import "React/RCTBridgeModule.h"
|
|
2
|
+
#import <React/RCTEventEmitter.h>
|
|
2
3
|
|
|
3
|
-
@interface RCT_EXTERN_MODULE(RNSmartMessage,
|
|
4
|
+
@interface RCT_EXTERN_MODULE(RNSmartMessage, RCTEventEmitter)
|
|
5
|
+
|
|
6
|
+
RCT_EXTERN_METHOD(registerCallback)
|
|
4
7
|
|
|
5
8
|
RCT_EXTERN_METHOD(requestNotificationPermission)
|
|
6
9
|
|
package/ios/RNSmartMessage.swift
CHANGED
|
@@ -2,9 +2,57 @@ import Foundation
|
|
|
2
2
|
import SmartMessageSdk
|
|
3
3
|
import UserNotificationsUI
|
|
4
4
|
import UserNotifications
|
|
5
|
+
import React
|
|
6
|
+
|
|
5
7
|
|
|
6
8
|
@objc(RNSmartMessage)
|
|
7
|
-
class RNSmartMessage:
|
|
9
|
+
class RNSmartMessage: RCTEventEmitter, NotificationCallbacksProtocol {
|
|
10
|
+
|
|
11
|
+
@objc
|
|
12
|
+
static func registerCallback(){
|
|
13
|
+
SmartMessage.shared.registerNotificationCallbacks(self as! NotificationCallbacksProtocol)
|
|
14
|
+
}
|
|
15
|
+
// 1. React Native'e ileteceğimiz event'lerin isimleri
|
|
16
|
+
override func supportedEvents() -> [String]! {
|
|
17
|
+
return [
|
|
18
|
+
"notificationReceived",
|
|
19
|
+
"notificationClicked",
|
|
20
|
+
"notificationButtonClicked",
|
|
21
|
+
"notificationDismissed"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 2. Main queue'da başlatılması gerekiyorsa true
|
|
26
|
+
@objc
|
|
27
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
28
|
+
return true
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 3. Modül init edildiğinde SDK callback'lerini register edin
|
|
32
|
+
override init() {
|
|
33
|
+
super.init()
|
|
34
|
+
SmartMessage.shared.registerNotificationCallbacks(self)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 4. Gelen her callback’te, React’e event gönderin
|
|
38
|
+
func didReceiveNotification(notification: [String: Any]) {
|
|
39
|
+
sendEvent(withName: "notificationReceived", body: notification)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
func didClickNotification(notification: [String: Any]) {
|
|
43
|
+
sendEvent(withName: "notificationClicked", body: notification)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
func didClickNotificationButton(notification: [String: Any], button: SmartMessageSdk.NotificationActionModel) {
|
|
47
|
+
// button modelini kendi JSON yapınıza çevirin
|
|
48
|
+
var payload = notification
|
|
49
|
+
payload["button"] = button.toDictionary()
|
|
50
|
+
sendEvent(withName: "notificationButtonClicked", body: payload)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
func didDismissNotification(notification: [String: Any]) {
|
|
54
|
+
sendEvent(withName: "notificationDismissed", body: notification)
|
|
55
|
+
}
|
|
8
56
|
|
|
9
57
|
static var token: String? = nil;
|
|
10
58
|
|
|
@@ -599,11 +647,6 @@ class RNSmartMessage: NSObject {
|
|
|
599
647
|
|
|
600
648
|
}
|
|
601
649
|
|
|
602
|
-
@objc
|
|
603
|
-
static func requiresMainQueueSetup() -> Bool {
|
|
604
|
-
return true
|
|
605
|
-
}
|
|
606
|
-
|
|
607
650
|
}
|
|
608
651
|
|
|
609
652
|
extension String {
|
|
@@ -658,3 +701,26 @@ extension UserInfoModel{
|
|
|
658
701
|
return ""
|
|
659
702
|
}
|
|
660
703
|
}
|
|
704
|
+
|
|
705
|
+
extension SmartMessageSdk.NotificationActionModel {
|
|
706
|
+
func toDictionary() -> [String: Any] {
|
|
707
|
+
let allProperties: [(String, Any?)] = [
|
|
708
|
+
("label", label),
|
|
709
|
+
("link", link),
|
|
710
|
+
("linkId", linkId),
|
|
711
|
+
("deeplinkType", deeplinkType),
|
|
712
|
+
("color", color),
|
|
713
|
+
("textColor", textColor)
|
|
714
|
+
]
|
|
715
|
+
|
|
716
|
+
// Dictionary<String, Any> olduğunu açıkça belirt
|
|
717
|
+
let dict = Dictionary<String, Any>(
|
|
718
|
+
uniqueKeysWithValues: allProperties.compactMap { key, value in
|
|
719
|
+
guard let v = value else { return nil }
|
|
720
|
+
return (key, v)
|
|
721
|
+
}
|
|
722
|
+
)
|
|
723
|
+
return dict
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|