Commit e09795ae authored by Wei Han's avatar Wei Han

ios working

parent 0f0a34cd
......@@ -79,7 +79,7 @@ export default function App() {
try {
if (CallDirectoryManager) {
const status = await CallDirectoryManager.getEnabledStatusForExtension(
"com.whoscall.app.CallDirectoryExtension"
"com.whoscall.whosallDirectoryExtension"
);
newStatuses['Call Directory Extension'] = status === 2 ? RESULTS.GRANTED : RESULTS.DENIED;
} else {
......@@ -122,6 +122,36 @@ export default function App() {
}
}
if (Platform.OS === 'ios') {
try {
if (CallDirectoryManager) {
const status = await CallDirectoryManager.getEnabledStatusForExtension(
"com.whoscall.whoscallDirectoryExtension"
);
let mapped: typeof RESULTS[keyof typeof RESULTS]; // tells TS it's a valid RESULTS value
if (status === 2) {
mapped = RESULTS.GRANTED; // enabled
} else if (status === 1) {
mapped = RESULTS.DENIED; // disabled by user
} else {
mapped = RESULTS.UNAVAILABLE; // unknown / not supported
}
newStatuses['Call Directory Extension'] = mapped;
} else {
console.warn("⚠️ CallDirectoryManager native module not available");
newStatuses['Call Directory Extension'] = RESULTS.DENIED;
Alert.alert(
"Enable Caller ID",
"Go to Settings → Phone → Call Blocking & Identification and enable [whoscall] to see caller ID labels.",
[
{ text: "Open Settings", onPress: () => Linking.openURL("app-settings:") },
{ text: "Cancel", style: "cancel" }
]
);
}
} catch (e) {
console.error("Error checking Call Directory extension:", e);
newStatuses['Call Directory Extension'] = RESULTS.DENIED;
Alert.alert(
"Enable Caller ID",
"Go to Settings → Phone → Call Blocking & Identification and enable [Your App] to see caller ID labels.",
......@@ -131,6 +161,7 @@ export default function App() {
]
);
}
}
}, []);
useEffect(() => {
......@@ -146,28 +177,28 @@ export default function App() {
const allGranted = Object.values(statuses).every(s => s === RESULTS.GRANTED);
// --- iOS: Call Directory management ---
const checkCallDirectoryStatus = async () => {
if (Platform.OS !== "ios" || !CallDirectoryManager) {
console.warn("CallDirectoryManager not available on this platform");
return;
}
try {
const status = await CallDirectoryManager.getEnabledStatusForExtension(
"com.whoscall.app.CallDirectoryExtension" // <-- must match your extension bundle ID
);
console.log("Call Directory status:", status);
if (status === 2) {
Alert.alert("✅ Enabled", "Call Directory Extension is enabled");
} else {
Alert.alert(
"⚠️ Not Enabled",
"Go to Settings → Phone → Call Blocking & Identification and enable Whoscall."
);
}
} catch (e) {
console.error("Error checking Call Directory status:", e);
}
};
// const checkCallDirectoryStatus = async () => {
// if (Platform.OS !== "ios" || !CallDirectoryManager) {
// console.warn("CallDirectoryManager not available on this platform");
// return;
// }
// try {
// const status = await CallDirectoryManager.getEnabledStatusForExtension(
// "com.whoscall.whoscallDirectoryExtension" // <-- must match your extension bundle ID
// );
// console.log("Call Directory status:", status);
// if (status === 2) {
// Alert.alert("✅ Enabled", "Call Directory Extension is enabled");
// } else {
// Alert.alert(
// "⚠️ Not Enabled",
// "Go to Settings → Phone → Call Blocking & Identification and enable Whoscall."
// );
// }
// } catch (e) {
// console.error("Error checking Call Directory status:", e);
// }
// };
const reloadCallDirectory = async () => {
if (Platform.OS !== "ios" || !CallDirectoryManager) {
......@@ -176,7 +207,7 @@ export default function App() {
}
try {
const success = await CallDirectoryManager.reloadExtension(
"com.whoscall.app.CallDirectoryExtension"
"com.whoscall.whoscallDirectoryExtension"
);
console.log("Reload result:", success);
if (success) {
......@@ -203,12 +234,10 @@ export default function App() {
</Text>
</View>
))}
{allGranted && <Text style={styles.granted}>All permissions granted ✅</Text>}
{Platform.OS === "android" && allGranted && <Text style={styles.granted}>All permissions granted ✅</Text>}
<Button title="Check Again" onPress={checkAllPermissions} />
{Platform.OS === "ios" && (
<>
<Button title="Check Call Directory Status" onPress={checkCallDirectoryStatus} />
<View style={{ height: 10 }} />
<Button title="Reload Call Directory" onPress={reloadCallDirectory} />
</>
)}
......
......@@ -366,6 +366,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = SLK4N5KC2N;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = whoscall/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
......@@ -379,7 +380,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.whoscall;
PRODUCT_NAME = whoscall;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
......@@ -394,6 +395,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = SLK4N5KC2N;
INFOPLIST_FILE = whoscall/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
LD_RUNPATH_SEARCH_PATHS = (
......@@ -406,7 +408,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.whoscall;
PRODUCT_NAME = whoscall;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
......@@ -427,6 +429,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = SLK4N5KC2N;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
......@@ -443,7 +446,7 @@
MARKETING_VERSION = 1.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.reactjs.native.example.whoscall.whoscallDirectoryExtension;
PRODUCT_BUNDLE_IDENTIFIER = com.whoscall.whoscallDirectoryExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
......@@ -469,6 +472,7 @@
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = SLK4N5KC2N;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
......@@ -484,7 +488,7 @@
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MARKETING_VERSION = 1.0;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.reactjs.native.example.whoscall.whoscallDirectoryExtension;
PRODUCT_BUNDLE_IDENTIFIER = com.whoscall.whoscallDirectoryExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_COMPILATION_MODE = wholemodule;
......
......@@ -19,10 +19,7 @@ class CallDirectoryHandler: CXCallDirectoryProvider {
// Example: add VIP numbers
// Numbers must be E.164 format (+60 for Malaysia)
let vipNumbers: [(number: Int64, label: String)] = [
(60189884118, "Wei Yi"),
(60123456789, "Spam Caller"),
(60122553372, "Someone Else"),
(60123456789, "Scam Caller"),
(60189884118, "Wei Han"),
]
for entry in vipNumbers {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment