Commit e09795ae authored by Wei Han's avatar Wei Han

ios working

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