I want to show related city name on call screen before phone number when incoming call.
Now, I detected incoming number like this:
id ct = CTTelephonyCenterGetDefault();
CTTelephonyCenterAddObserver( ct, NULL, callback,NULL,NULL, CFNotificationSuspensionBehaviorHold);
and related city name was figure out , but how to show it?
I searched an answer: hook SBCallAlertDisplay or SBCallAlert, but in ios5 SpringBoard headers i can't find these! Maybe it works before ios5 but my version is ios5.1.
OK, The result is here: (cydia dev) Call Answering Screen in iPhone
Related
I'm stumped, iOS 11.4 ( 15F79 ), iPhone 6. Cannot get the App to Ask for Motion Data. info.plist has been set via the editor and double checked via the info.plist open in textWrangler, Also deleted key and saved via textWrangler.
<key>NSMotionUsageDescription</key>
<string>This app needs your Phones motion manager to update when the phone is tilted. Please allow this App to use your phones tilt devices</string>
I have deleted then reinstalled the app about 10 times. I have restared the phone 5 times. I have checked through settings and my app does NOT show up in Privacy-Motion and Fitness or anywhere else in settings. I am using a free developer account, maybe that has something to do with it?
I created a new Xcode game template and changed nothing apart from importing CoreMotion and this code
**** Edited, sorry I forgot to say I had started the instance, just forgot to put it here, just in case someone thinks that's the problem ************
let motionManager = CMMotionManager()
override func didMove(to view: SKView) {
motionManager.startDeviceMotionUpdates()
if motionManager.isDeviceMotionActive == true {
motionManager.accelerometerUpdateInterval = 0.2
motionManager.startAccelerometerUpdates(to: OperationQueue.current!, withHandler: {
(accelerometerData: CMAccelerometerData!, error: NSError!) in
let acceleration = accelerometerData.acceleration
print(accelerometerData)
} as! CMAccelerometerHandler)
}else{
print(CMMotionActivityManager.authorizationStatus().rawValue)
}
which prints a 0 ( an Enum - case not determined ) to the console.
In my actual app it was a 3 ( same Enum - case Denied ).
As I've said, I have uninstalled, reinstalled, edited plist via Xcode and text wrangler ( a code editor ) , tried different versions of the code above, tried the code in different places ( in did move to view, in class )tried code off apple docs. etc.... I haven't been asked the NSUsage question and the App keeps crashing.
I have looked for ways to get the Alert fired up, As in CLLocationManager.requestWhenInUseAuthorization() but I cannot find a comparable CMMotion version ( I don't think there is one. ) I have created a new swift file , imported Foundation and CMMotion and just put that code there, But still no Alert asking for Motion Data.
I tried a single view app template instead of a game template thinking that might be the issue, Nope.
What do I do?
Any help Appreciated. Thanks
You are confusing two related but different classes.
CMMotionManager gives access to accelerometer, magnetometer and gyroscope data. It does not require any user permission as this information is not considered privacy related.
In your else clause you are checking the authorisation status of CMMotionActivityManager. This object reports the device motion type (walking, running, driving). This information is considered privacy related and when you create an instance of this class and request data from it, the permissions alert is displayed.
The reason your else is being triggered is because you are checking isDeviceMotionActive; this will be false until you call startDeviceMotionUpdates, which you never do. Even if you used isAccelerometerActive you would have a problem because you call startAccelerometerUpdates in the if clause which will never be reached.
You probably meant to check isAccelerometerAvailable. If this returns false then there isn't much you can do; the device doesn't have an accelerometer.
Update
It doesn't make sense to check isDeviceMotionActive immediately after calling startDeviceMotion:
You know it's active; you just started it
I imagine the start up takes some time, so you could expect to get false if you check immediately.
Apple recommends that you do not have more than one observer in place for each motion device type, so the purpose of check the is...Active to ensure you don't call start... again if you have already done so.
If you only want gyroscope data then you don't need to call startDeviceMotionUpdates at all.
I'm writing a upper class filter for WPD device. I specified the callback functions for the Read/Write/Ioctl, from the callback declaration I could get the WDFQueue, WDFRequest.
VOID WdfFltrDeviceControl(IN WDFQUEUE Queue, IN WDFREQUEST Request, IN size_t OutputBufferLength, IN size_t InputBufferLength, IN ULONG IoControlCode)
But from the parameter Queue or Request, I could only get the information of device which is created by my driver. Is there any way to retrieve the informations of the attached devices which my driver is currently filtering?(e.g. From the kernel log I can see the ioctl request to my android device, but I don't know how to get the android device object to get the device name)
You are really should be able to get information about your WPD device request using parameters of this method. If you are not, probably your code or .inf filter setup is wrong.
You can use this code snippet to check what device you are filtering now:
WDFDEVICE device = WdfIoQueueGetDevice(Queue);
WCHAR id[255];
ULONG resultLength;
NTSTATUS status = WdfDeviceQueryProperty(device, DevicePropertyHardwareID, sizeof(id), id, &resultLength);
if(NT_SUCCESS(status))
{
//check the device id here
}
Or, if you prefer some another parameter, you could find the list here
I am having an issue where the ABPeoplePickerNavigationController seems to be returning the wrong identifier for contacts that have phone numbers synchronized from both Exchange and iCloud. My application is running on iOS 7.1 and is compiled with iOS 7.1 SDK.
TL;DR - In the people picker delegate callback I am getting the wrong identifier when I have a contact that has phone numbers from both Exchange and iCloud merged together.
Preemptive Answer: Yes I am calling ABMultiValueGetIndexForIdentifier.
This problem only happens when I have a single contact with phone numbers from both Exchange and iCloud. I ran an older version of the application compiled with iOS 6.1 SDK and it does not have the problem when running under iOS 7.1.
I have simplified the test down to:
iPhone is registered to iCloud with Contact syncing enabled. The iPhone also is setup to check mail with Exchange. In Exchange. I have a contact called "Foo Bar" with three phone numbers and this contact displays in iPhone correctly. At this point everything is working as expected in my application:
Work: 212-111-1111
Mobile: 212-222-2222
Home: 212-333-3333
Work Fax: 212-444-4444
iPad is registered to iCloud with Contact syncing enabled. Email is not configured on this device. I created a user named "Foo Bar" with two phone numbers:
Home Fax: 212-555-5555
Work Fax: 212-666-6666
After the iCloud syncs the contacts I see that "Foo Bar" has 6 phone numbers in the iOS contacts app on the iPhone. Dialing from the iOS contacts app dials the correct number.
In my application I am displaying an ABPeoplePickerNavigationController. In the delegate callback I am getting the wrong phone number.
In the people picker I see the contact with all 6 phone numbers in this order:
Work: 212-111-1111
Work Fax: 212-444-4444
Home: 212-333-3333
Mobile: 212-222-2222
Home Fax: 212-555-5555
Work Fax: 212-666-6666
In the delegate I am displaying all of the phone numbers and they always display in this order. It looks like the iCloud entries are in the list above the Exchange numbers (not that it should matter).
xindex:0 phone:(212) 555-5555
xindex:1 phone:(212) 666-6666
xindex:2 phone:(212) 111-1111
xindex:3 phone:(212) 444-4444
xindex:4 phone:(212) 333-3333
xindex:5 phone:(212) 222-2222
As I select each entry in the from the people picker I get these results in the people picker delegate:
Work Phone: identifier=0 index=0 phone=(212) 555-5555 (wrong:should be 212-111-1111)
Work Fax: identifier=1 index=1 phone=(212) 666-6666 (wrong:should be 212-444-4444)
Home: identifier=2 index=2 phone=(212) 111-1111 (wrong:should be 212-333-3333)
Mobile: identifier=3 index=3 phone=(212) 444-4444 (wrong:should be 212-222-2222)
Home Fax: identifier=0 index=0 phone=(212) 555-5555 (correct)
Work Fax: identifier=1 index=1 phone=(212) 666-6666 (correct)
It looks like the identifier being passed to the delegate is not correct since 0 and 1 are used for 2 different entries. It could also be that the identifier to index mapping is also not correct.
Here is my simplified delegate callback:
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
if (property == kABPersonPhoneProperty) {
ABMutableMultiValueRef multi = ABRecordCopyValue(person, property);
if (multi != NULL) {
//Display all the phone numbers for the object
CFIndex xcount = ABMultiValueGetCount(multi);
NSLog(#"xcount = %lu", (unsigned long)xcount);
for (CFIndex xindex = 0 ; xindex < xcount ; ++xindex) {
CFStringRef xphone = (CFStringRef)ABMultiValueCopyValueAtIndex(multi, xindex);
NSLog(#"xindex:%ld phone:%#", (long)xindex, (__bridge NSString*)xphone);
if (xphone) { CFRelease(xphone); }
}
//Display the selected phone number
CFIndex itemIndex = ABMultiValueGetIndexForIdentifier(multi, identifier);
CFStringRef phone = (CFStringRef)ABMultiValueCopyValueAtIndex(multi, itemIndex);
NSLog(#"identifier:%ld itemIndex:%ld phone:%#", (long)identifier, (long)itemIndex, (__bridge NSString*)phone);
if (phone) { CFRelease(phone); }
CFRelease(multi);
}
}
return NO;
}
I would expect to see a different identifier for each phone number that would map to the correct index number. Is there a step I am missing? Is this a bug in iOS 7?
Any help or insight is appreciated.
ABMultiValueGetIndexForIdentifier() (or the data behind it) is definitely broken in iOS 8 and 9. I can't tell for iOS 7 since we didn't had crash tracking back then. Example:
Have a new contact with 2 addresses
Identifiers are now (0, 1) and the corresponding indexes (0, 1) which is correct
Delete the first address
Identifier for the remaining address is (1) and the index (-1)
That the identifier remains 1 is understandable, as it is an identifier. But the index should be 0. What happens becomes more obvious when you use 3 addresses:
(0, 1, 2) and (0, 1, 2)
Delete first address
Becomes (1, 2) and (1, -1)
Clicking the first address returns the second one
Clicking the second address results in a crash (if you don't check for index -1 which you actually should not have to in the first place)
ABMultiValueGetIndexForIdentifier seems to return the identifier if the id exists as an index or -1 if the id exceeds the index range.
I tried to attack from a different angle but ABMultiValueGetIdentifierAtIndex seems broken, too. So iterating over the entries does not help either. ABMultiValueGetIdentifierAtIndex always seems to return the index itself (iOS 9).
So far I have to assume that this is a bug in iOS. If I use my test-contact in other apps they seem to have the exact same issue. Given your data it looks like the identifiers and the id-to-index-mapping really are broken. For me the ids were reasonable (at least).
I think reporting won't help since the ABPeoplePicker got discontinued with iOS 9.
I'm aware that this is a question already asked, I've found possible duplicates:
Detecting if headphones are plugged into iPhone
headphone plug-in plug-out event when audio route doesn't change - iOS
Detect if headphones (not microphone) are plugged in to an iOS device
...and more info on the WWW. But I've tried out every solution given and everytime I have problem, probably because they are old threads and are referring to iOS 4.
How can I detect it on iOS 5.0?
Thanks
If you're okay with an iOS 6-only solution, Apple added several new AVAudioSession properties that let you detect audio routes in just a few lines (and without the use of C).
Use this method to check for headphones (or adjust it to check for other outputs - "Speaker", "Headset", etc.):
- (BOOL)isHeadsetPluggedIn
{
// Get array of current audio outputs (there should only be one)
NSArray *outputs = [[AVAudioSession sharedInstance] currentRoute].outputs;
NSString *portName = [[outputs objectAtIndex:0] portName];
if ([portName isEqualToString:#"Headphones"]) {
return YES;
}
return NO;
}
If you want to respond to audio route changes passively, you can do this with the new NSNotification, AVAudioSessionRouteChangeNotification. Unfortunately, this notification doesn't tell you what the new route is, just the previous route that it switched from. But, you can just call some variation of the method above to get the current route.
Wes seems to have a great solution. Alas it is not international-proof. This code only works for the English language. In Dutch, for instance, the headset is called 'Koptelefoon' and
*portName
contains indeed 'Koptelefoon' which makes the test fail.
This will do the job internationally correct:
if ([portDescription.portType isEqualToString:AVAudioSessionPortHeadphones])
;
Im stuck to get own phone number and Sim ID (SSID) using Monotouch
I tryed:
var v = NSUserDefaults.StandardUserDefaults.ValueForKey((NSString)#"SBFormattedPhoneNumber");
var t = NSUserDefaults.StandardUserDefaults.ValueForKey((NSString)#"ICCID");
new UIAlertView("Ur phone Number",""+v.ToString(),null,"Ok",null).Show();
new UIAlertView("Ur ICCID",""+t.ToString(),null,"Ok",null).Show();
and all other ValueFor***
it always return null or " "
Tried on iphone 3g. Please help.
Apple does not want to to access this information as it can easily be misused. Any application doing so is likely to be rejected from the AppStore. See the comment (with more than 30 up votes) from this answer.
Also note that your code above does not read from the SIM - it reads from the iTunes registration data, which does not have to be set to any value (i.e. you can't trust it).