peterhajas / MobileNotifier

iOS Notifications. Done right.
BSD 3-Clause "New" or "Revised" License
302 stars 32 forks source link

Here's the commit you asked for on notifications #266

Closed sammargh closed 13 years ago

sammargh commented 13 years ago

I played with the code a little more and noticed that AudioServicesPlayAlertSound actually does all the legwork for you in regards to vibration so it only has to be 2 lines of code.

I know where the actual ringtone setting resides on ios but my knowledge of how to get it is minimal as I have no work with the private apis. It resides in /private/var/mobile/Library/Preferences/com.apple.springboard.plist under the key name sms-sound-identifier in the form texttone:Horn. I figure you could use a NSReader to get the value and use a method to convert the key contents to a system tone based on the returned key value.

Unfortunately my knowledge of ios in general is rather lacking and as far as I can tell you need to use sandboxing to gain access to the file, although in jailbroken perhaps this is unnecessary. Anyways I figured this information might help you correct it entirely as the rest of the function is beyond my ability.

timnovinger commented 13 years ago

Thanks for the contribution @sammargh, I'll investigate this further.

Drudoo commented 13 years ago

After a lot of testing and trying i gave up on this ;) So far i have:

    NSString *filePath = @"/private/var/mobile/Library/Preferences/com.apple.springboard.plist";
    NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];

    NSString *smsTone;
    smsTone = [plistDict objectForKey:@"sms-sound-identifier"];

//need one smsTone for each of the tones and then point to the correct sms-recievedX.caf if(smsTone == @"texttone:Chime") { AudioServicesPlaySystemSound(1007); }

timnovinger commented 13 years ago

@peterhajas any ideas concerning this?

ghost commented 13 years ago

u should merge this. This would be a great thing. Only if you could change the audio tone to anything or custom not just tri-tone

Drudoo commented 13 years ago

@ymarcus None of this is working right now. No use in merging it.

Sent from a Random Apple Device

On 03/06/2011, at 22.55, ymarcusreply@reply.github.com wrote:

u should merge this. This would be a great thing. Only if you could change the audio tone to anything or custom not just tri-tone

Reply to this email directly or view it on GitHub: https://github.com/peterhajas/MobileNotifier/pull/266#issuecomment-1299383

sammargh commented 13 years ago

@Drudoo the initial code I provided fixes the issue of if a user has vibration disabled on their phone to not vibrate the phone in either silenced or non-silenced mode. While it doesn't fix the notification tone issue yet it does fix that.

Drudoo commented 13 years ago

Ah yes of course.

On Jun 4, 2011, at 6:21 PM, sammargh wrote:

@Drudoo the initial code I provided fixes the issue of if a user has vibration disabled on their phone to not vibrate the phone in either silenced or non-silenced mode. While it doesn't fix the notification tone issue yet it does fix that.

Reply to this email directly or view it on GitHub: https://github.com/peterhajas/MobileNotifier/pull/266#issuecomment-1302047

Sent from a Random Apple Device

sammargh commented 13 years ago

@Drudoo I took your code and finished it up. Going to close this pull request and open a new one. Notifications are working properly now :)