Skip to content

Commit

Permalink
fix: iOS | Trigger "NotificationClickV2" (#71)
Browse files Browse the repository at this point in the history
Update the iOS library to use the latest version that enables the correct triggering of the new NotificationClick event.
Update the implementation of the "FirebaseMessagingEventProtocol" to trigger multiple events simultaneously, including the new NotificationClick event.
Extend OSFCMClickableType and FirebaseNotificationType to implement the CustomStringConvertible protocol, applying the correct value to the description property.
  • Loading branch information
OS-ricardomoreirasilva authored and OS-martacarlos committed May 21, 2024
1 parent 52b1165 commit 06ef073
Show file tree
Hide file tree
Showing 26 changed files with 20,595 additions and 148 deletions.
1 change: 1 addition & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
</config-file>

<!-- iOS Source Files -->
<source-file src="src/ios/OSFCMEventExtensions.swift" />
<source-file src="src/ios/OSFirebaseCloudMessaging.swift" />
<header-file src="src/ios/AppDelegate+OSFirebaseCloudMessaging.h" />
<source-file src="src/ios/AppDelegate+OSFirebaseCloudMessaging.m" />
Expand Down
24 changes: 24 additions & 0 deletions src/ios/OSFCMEventExtensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import OSFirebaseMessagingLib

extension OSFCMClickableType: CustomStringConvertible {
public var description: String {
var result: String
switch self {
case .notification(latestVersion: let latestVersion):
result = "notificationClick"
if latestVersion {
result += "V2"
}
case .action:
result = "interalRouteActionClick"
@unknown default:
preconditionFailure("Not supposed to get here")
}

return result
}
}

extension FirebaseNotificationType: CustomStringConvertible {
public var description: String { "\(self == .silentNotification ? "silent": "default")Notification" }
}
6 changes: 4 additions & 2 deletions src/ios/OSFirebaseCloudMessaging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,11 @@ extension OSFirebaseCloudMessaging: FirebaseMessagingEventProtocol {

switch event {
case .click(type: let type):
eventName = type == .notification ? "notificationClick" : "internalRouteActionClick"
eventName = type.description
case .trigger(notification: let notification):
eventName = notification == .silentNotification ? "silentNotification" : "defaultNotification"
eventName = notification.description
@unknown default:
preconditionFailure("Not supposed to get here")
}

self.trigger(event: eventName, data: data)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Generated by Apple Swift version 5.6.1 (swiftlang-5.6.0.323.66 clang-1316.0.20.12)
#if 0
#elif defined(__arm64__) && __arm64__
// Generated by Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)
#ifndef OSFIREBASEMESSAGINGLIB_SWIFT_H
#define OSFIREBASEMESSAGINGLIB_SWIFT_H
#pragma clang diagnostic push
Expand All @@ -21,11 +23,20 @@
# include <swift/objc-prologue.h>
#endif

#pragma clang diagnostic ignored "-Wduplicate-method-match"
#pragma clang diagnostic ignored "-Wauto-import"
#if defined(__OBJC__)
#include <Foundation/Foundation.h>
#endif
#if defined(__cplusplus)
#include <cstdint>
#include <cstddef>
#include <cstdbool>
#else
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#endif

#if !defined(SWIFT_TYPEDEFS)
# define SWIFT_TYPEDEFS 1
Expand Down Expand Up @@ -181,16 +192,40 @@ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
#else
# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)
#endif
#if defined(__OBJC__)
#if !defined(IBSegueAction)
# define IBSegueAction
#endif
#endif
#if !defined(SWIFT_EXTERN)
# if defined(__cplusplus)
# define SWIFT_EXTERN extern "C"
# else
# define SWIFT_EXTERN extern
# endif
#endif
#if !defined(SWIFT_CALL)
# define SWIFT_CALL __attribute__((swiftcall))
#endif
#if defined(__cplusplus)
#if !defined(SWIFT_NOEXCEPT)
# define SWIFT_NOEXCEPT noexcept
#endif
#else
#if !defined(SWIFT_NOEXCEPT)
# define SWIFT_NOEXCEPT
#endif
#endif
#if defined(__cplusplus)
#if !defined(SWIFT_CXX_INT_DEFINED)
#define SWIFT_CXX_INT_DEFINED
namespace swift {
using Int = ptrdiff_t;
using UInt = size_t;
}
#endif
#endif
#if defined(__OBJC__)
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
Expand All @@ -202,13 +237,15 @@ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
@import UserNotifications;
#endif

#endif
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
#if __has_warning("-Wpragma-clang-attribute")
# pragma clang diagnostic ignored "-Wpragma-clang-attribute"
#endif
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wnullability"
#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"

#if __has_attribute(external_source_symbol)
# pragma push_macro("any")
Expand All @@ -217,6 +254,7 @@ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
# pragma pop_macro("any")
#endif

#if defined(__OBJC__)

/// Object that manages all accesses to the Core Data layer
SWIFT_CLASS("_TtC22OSFirebaseMessagingLib15CoreDataManager")
Expand Down Expand Up @@ -356,8 +394,15 @@ SWIFT_CLASS_NAMED("OSFCMNotification")



#endif
#if defined(__cplusplus)
#endif
#if __has_attribute(external_source_symbol)
# pragma clang attribute pop
#endif
#pragma clang diagnostic pop
#endif

#else
#error unsupported Swift architecture
#endif
Binary file not shown.
Loading

0 comments on commit 06ef073

Please sign in to comment.