Skip to content
This repository has been archived by the owner on Sep 14, 2024. It is now read-only.

Commit

Permalink
feat: api updates
Browse files Browse the repository at this point in the history
  • Loading branch information
gtokman committed Feb 11, 2024
1 parent bbcec72 commit 6aebf99
Show file tree
Hide file tree
Showing 13 changed files with 241 additions and 298 deletions.
1 change: 1 addition & 0 deletions candlefinance-push.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Pod::Spec.new do |s|
s.homepage = package["homepage"]
s.license = package["license"]
s.authors = package["author"]
s.swift_version = "5.0"

s.platforms = { :ios => "15.0" }
s.source = { :git => "https://github.com/candlefinance/push.git", :tag => "#{s.version}" }
Expand Down
58 changes: 58 additions & 0 deletions example/ios/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,61 @@
//

import Foundation
import UIKit
import React
import candlefinance_push // 0
import NotificationCenter // 1

@UIApplicationMain
class AppDelegate: RCTAppDelegate {

// 2
let push = Push()

var isDarkMode: Bool {
return UITraitCollection.current.userInterfaceStyle == .dark
}

override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.moduleName = "PushExample"
UNUserNotificationCenter.current().delegate = self // 3
let result = super.application(application, didFinishLaunchingWithOptions: launchOptions)

return result
}

override func sourceURL(for bridge: RCTBridge!) -> URL! {
//#if DEBUG
print("DEBUG")
return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
//#else
// print("PROD")
// return Bundle.main.url(forResource: "main", withExtension: "jsbundle")
//#endif
}

}

extension AppDelegate: UNUserNotificationCenterDelegate {

override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
push.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
}

override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
push.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
}

public func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
push.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
}

public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
await push.userNotificationCenter(center, didReceive: response)
}

override func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
push.application(application, didReceiveRemoteNotification: userInfo, fetchCompletionHandler: completionHandler)
}

}
4 changes: 3 additions & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ prepare_react_native_project!
# dependencies: {
# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# ```
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
flipper_config = FlipperConfiguration.disabled

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Expand All @@ -30,6 +30,8 @@ target 'PushExample' do

use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => false,
:fabric_enabled => false,
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
Expand Down
Loading

0 comments on commit 6aebf99

Please sign in to comment.