Remove Widget and Notification Features
Remove all widget and notification features
If you temporarily don't need widget and notification features, you can follow the steps below to remove related code and configurations
Remove Widgets
- Delete the
EasyAppWidgetfolder, selectMove to Trash

- Right-click to delete
EasyAppWidgetExtension

- Uncheck
widgetinApp Group, as shown in step 3 of the image below

- Delete the
App -> Developer -> SubPages -> LiveActivityfolder, selectMove to Trash

- Go to
App -> Developer -> View -> DeveloperView.swiftfile, delete the code




- Go to
EasyAppSwiftUIApp.swiftfile, delete the followingwidgetrelated code
#if DEBUG
@State private var showLiveActivityDemo = false
@State private var showWidgetMicrophoneDemo = false
@State private var showWidgetCameraDemo = false
#endif // live activity
.onOpenURL { url in
devLogger.info("onOpenURL: \(url)")
let liveActivityValue = url.getEaspAppDeepLinkUrlParam(
hostKey: "live-activity", name: "path")
let widgetMicrophoneValue = url.getEaspAppDeepLinkUrlParam(
hostKey: "microphone", name: "path")
let widgetCameraValue = url.getEaspAppDeepLinkUrlParam(
hostKey: "camera", name: "path")
if let liveActivityValue, liveActivityValue == "live-activity" {
showLiveActivityDemo.toggle()
}
if let widgetMicrophoneValue, widgetMicrophoneValue == "microphone" {
showWidgetMicrophoneDemo.toggle()
}
if let widgetCameraValue, widgetCameraValue == "camera" {
showWidgetCameraDemo.toggle()
}
}
// widget
.sheet(isPresented: $showWidgetMicrophoneDemo) {
OpenWidgetMicrophoneDemo()
}
.sheet(isPresented: $showWidgetCameraDemo) {
OpenWidgetCameraDemo()
}Remove Notification Features
- Remove the dependency on
EasyAppNotifyKitlibrary

Select EasyAppNotifyKit, click the - button (might fail, try multiple times)

- Delete notification permissions
Uncheck Notifications permission


- Search and delete the following imported libraries in the
EasyAppSwiftUIproject
import EasyAppNotifyKit
import OneSignalFramework- Delete/comment out the related code in the
EasyAppSwiftUI/Lib/Auth/AuthManager.swiftfile
PushManager.shared.loginUser(userId) PushManager.shared.logoutUser()- Delete the following content, select
Move to Trash



- Go to
EasyAppSwiftUI/App/Developer/View/DeveloperView.swift, delete the code



-
Uncheck

- Go to
EasyAppSwiftUIApp.swiftfile, delete the followingnotificationrelated code
- Go to
#if DEBUG
@State private var showDeepLinkTest = false
#endif // Show the deep link test view when the notification is clicked
#if DEBUG
.sheet(isPresented: $showDeepLinkTest) {
OSDeepLinkTargetTestView()
}
.onReceive(
NotificationCenter.default.publisher(
for: EasyAppNotifyKit.Notifications.osNotificationClicked)
) { notification in
let deeplink = notification.userInfo?["deeplink"] as? String
if let deeplink, deeplink == "EasyApp://notifykit?screen=osTests" {
withAnimation(.spring(response: 0.5, dampingFraction: 0.8)) {
showDeepLinkTest = true
}
}
}
#endif if Constants.OneSignal.isEnabledNotification {
let oneSignalService = OneSignalService()
PushManager.shared.configure(with: oneSignalService)
let configuration: PushServiceConfiguration = PushServiceConfiguration(
appId: Constants.OneSignal.appId,
launchOptions: launchOptions
)
PushManager.shared.initialize(with: configuration)
OneSignal.Notifications.addClickListener(self)
OneSignal.Notifications.addForegroundLifecycleListener(self)
}extension AppDelegate: OSNotificationClickListener, OSNotificationLifecycleListener {
func onClick(event: OSNotificationClickEvent) {
devLogger.info("Notification clicked: \(event.jsonRepresentation())")
self.handleViewTap(additionalData: event.notification.additionalData)
}
func onWillDisplay(event: OSNotificationWillDisplayEvent) {
devLogger.info("Foreground notification: \(event.notification.title ?? "No Title")")
event.preventDefault()
guard let notifTitle = event.notification.title,
let notifMessage = event.notification.body,
let additionalData = event.notification.additionalData,
let symbol = additionalData["symbolImage"] as? String
else {
event.notification.display() // Show notification as usual
return
}
var notifHaptics: UINotificationFeedbackGenerator.FeedbackType = .warning
if let size = additionalData["status"] as? String {
if size == "error" {
notifHaptics = .error
} else if size == "success" {
notifHaptics = .success
}
UINotificationFeedbackGenerator().notificationOccurred(notifHaptics)
}
ShowNotification.showInAppNotification(
title: notifTitle,
message: notifMessage,
isSuccess: notifHaptics == .success,
duration: .seconds(seconds: 5),
systemImage: symbol,
handleViewTap: {
self.handleViewTap(additionalData: event.notification.additionalData)
}
)
}
/// Handle the view tap
/// - Parameter additionalData: the additional data
private func handleViewTap(additionalData: [AnyHashable: Any]? = nil) {
// Parse the additional data
let ad = JSON(additionalData ?? [:])
// Get the deeplink
let deeplink = ad["deeplink"].stringValue
if !deeplink.isEmpty {
// Broadcast click to allow host views to react (e.g., navigate)
NotificationCenter.default.post(
name: EasyAppNotifyKit.Notifications.osNotificationClicked,
object: nil,
userInfo: [
"deeplink": deeplink
]
)
}
}
}Finally, run the Cmd + B command to check for any other errors.
Last updated on