Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No alert dialog when changed? #14

Open
zRelux opened this issue Dec 18, 2023 · 5 comments
Open

No alert dialog when changed? #14

zRelux opened this issue Dec 18, 2023 · 5 comments

Comments

@zRelux
Copy link

zRelux commented Dec 18, 2023

How come there is no default alert dialog when the icon gets changed? I thought it was enabled by default

@outsung
Copy link
Owner

outsung commented Dec 25, 2023

Android doesn't have an alert.
I disabled alert because I wanted it to work the same way as ios and Android.

Do you want to enable alert?

@shanoysinc
Copy link

yes how do you enable the alert that the icon has changed?

@apokusin
Copy link

apokusin commented Jan 7, 2024

I agree that we should be able to configure this when calling setAppIcon. I'd prefer this to behave as users expect on the platform they're using. They don't really care if it works the same way on both platforms.

As a side note, I've disabled changing app icon on Android until the quality gets better. (see #3 )

@BR19-gh
Copy link

BR19-gh commented Jul 29, 2024

Is there a way to enable the alert for iOS?

@zRelux
Copy link
Author

zRelux commented Jul 29, 2024

For who's looking to enable the alert on iOS here's the patch:

diff --git a/node_modules/expo-dynamic-app-icon/android/build.gradle b/node_modules/expo-dynamic-app-icon/android/build.gradle
index a50832e..6566c7c 100644
--- a/node_modules/expo-dynamic-app-icon/android/build.gradle
+++ b/node_modules/expo-dynamic-app-icon/android/build.gradle
@@ -22,7 +22,7 @@ buildscript {
     if (ext.has("kotlinVersion")) {
       ext.kotlinVersion()
     } else {
-      ext.safeExtGet("kotlinVersion", "1.6.10")
+      ext.safeExtGet("kotlinVersion", "1.8.10")
     }
   }
 
@@ -52,20 +52,23 @@ afterEvaluate {
 
 android {
   namespace = "expo.modules.dynamicappicon"
-  compileSdkVersion safeExtGet("compileSdkVersion", 31)
+  compileSdkVersion safeExtGet("compileSdkVersion", 33)
 
-  compileOptions {
-    sourceCompatibility JavaVersion.VERSION_11
-    targetCompatibility JavaVersion.VERSION_11
-  }
+  def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
+  if (agpVersion.tokenize('.')[0].toInteger() < 8) {
+    compileOptions {
+      sourceCompatibility JavaVersion.VERSION_11
+      targetCompatibility JavaVersion.VERSION_11
+    }
 
-  kotlinOptions {
-    jvmTarget = JavaVersion.VERSION_11.majorVersion
+    kotlinOptions {
+      jvmTarget = JavaVersion.VERSION_11.majorVersion
+    }
   }
 
   defaultConfig {
     minSdkVersion safeExtGet("minSdkVersion", 21)
-    targetSdkVersion safeExtGet("targetSdkVersion", 31)
+    targetSdkVersion safeExtGet("targetSdkVersion", 34)
     versionCode 1
     versionName "0.1.0"
   }
diff --git a/node_modules/expo-dynamic-app-icon/ios/ExpoDynamicAppIconModule.swift b/node_modules/expo-dynamic-app-icon/ios/ExpoDynamicAppIconModule.swift
index 429bfe2..f8da875 100644
--- a/node_modules/expo-dynamic-app-icon/ios/ExpoDynamicAppIconModule.swift
+++ b/node_modules/expo-dynamic-app-icon/ios/ExpoDynamicAppIconModule.swift
@@ -6,7 +6,7 @@ public class ExpoDynamicAppIconModule: Module {
     Name("ExpoDynamicAppIcon")
 
     Function("setAppIcon") { (name:String) -> String in
-      self.setAppIconWithoutAlert(name)
+      self.setAppIcon(name)
 
       return name
     }
@@ -16,16 +16,9 @@ public class ExpoDynamicAppIconModule: Module {
     }
   }
 
-  private func setAppIconWithoutAlert(_ iconName: String?) {
+  private func setAppIcon(_ iconName: String?) {
     if UIApplication.shared.responds(to: #selector(getter: UIApplication.supportsAlternateIcons)) && UIApplication.shared.supportsAlternateIcons {
-      typealias setAlternateIconName = @convention(c) (NSObject, Selector, NSString?, @escaping (NSError) -> ()) -> ()
-      
-      let selectorString = "_setAlternateIconName:completionHandler:"
-      
-      let selector = NSSelectorFromString(selectorString)
-      let imp = UIApplication.shared.method(for: selector)
-      let method = unsafeBitCast(imp, to: setAlternateIconName.self)
-      method(UIApplication.shared, selector, iconName as NSString?, { _ in })
+      UIApplication.shared.setAlternateIconName(iconName)
     }
   }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants