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
31 changes: 31 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// swift-tools-version: 5.9
import PackageDescription

let package = Package(
name: "CapacitorCommunityFirebaseAnalytics",
platforms: [.iOS(.v15)],
products: [
.library(
name: "CapacitorCommunityFirebaseAnalytics",
targets: ["Plugin"])
],
dependencies: [
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0"),
.package(url: "https://github.com/firebase/firebase-ios-sdk", from: "12.3.0")
],
targets: [
.target(
name: "Plugin",
dependencies: [
.product(name: "Capacitor", package: "capacitor-swift-pm"),
.product(name: "Cordova", package: "capacitor-swift-pm"),
.product(name: "FirebaseCore", package: "firebase-ios-sdk"),
.product(name: "FirebaseAnalytics", package: "firebase-ios-sdk"),
],
path: "ios/Plugin"),
.testTarget(
name: "PluginTests",
dependencies: ["Plugin"],
path: "ios/PluginTests")
]
)
10 changes: 0 additions & 10 deletions ios/Plugin/Plugin.h

This file was deleted.

15 changes: 0 additions & 15 deletions ios/Plugin/Plugin.m

This file was deleted.

19 changes: 17 additions & 2 deletions ios/Plugin/Plugin.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
import Foundation
import Cordova
import Capacitor
import FirebaseCore
import FirebaseAnalytics

@objc(FirebaseAnalytics)
public class FirebaseAnalytics: CAPPlugin {
public class FirebaseAnalytics: CAPPlugin, CAPBridgedPlugin {
public let identifier = "FirebaseAnalyticsPlugin"
public let jsName = "FirebaseAnalytics"
public let pluginMethods: [CAPPluginMethod] = [
CAPPluginMethod(name: "setUserId", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "setUserProperty", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "getAppInstanceId", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "setScreenName", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "reset", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "logEvent", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "setCollectionEnabled", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "setSessionTimeoutDuration", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "enable", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "disable", returnType: CAPPluginReturnPromise)
]

public override func load() {
if FirebaseApp.app() == nil {
Expand Down Expand Up @@ -42,7 +57,7 @@ public class FirebaseAnalytics: CAPPlugin {
/// Retrieves the app instance id from the service.
/// - Parameter call: instanceId - current instance if of the app
@objc func getAppInstanceId(_ call: CAPPluginCall) {
let instanceId = Analytics.appInstanceID()
let instanceId = Analytics.appInstanceID() ?? ""
call.resolve([
"instanceId": instanceId
])
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"android/build.gradle",
"dist/",
"ios/Plugin/",
"CapacitorCommunityFirebaseAnalytics.podspec"
"CapacitorCommunityFirebaseAnalytics.podspec",
"Package.swift"
],
"keywords": [
"capacitor",
Expand Down