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

(ios) Fix warning in CDVNotification.m: Cast to smaller integer type 'int' from 'void *' #156

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
(ios) Fix warning in CDVNotification.m: Cast to smaller integer type …
…'int' from 'void *'
  • Loading branch information
nacho4d committed Dec 12, 2021
commit c8ff56af65c7957e01a8c71e1dafabeee9b436c4
11 changes: 9 additions & 2 deletions src/ios/CDVNotification.m
Original file line number Diff line number Diff line change
@@ -121,18 +121,25 @@ - (void)prompt:(CDVInvokedUrlCommand*)command
static void playBeep(int count) {
SystemSoundID completeSound;
NSInteger cbDataCount = count;
NSNumber *cbDataCountNumber = @(cbDataCount-1);
NSURL* audioPath = [[NSBundle mainBundle] URLForResource:@"CDVNotification.bundle/beep" withExtension:@"wav"];
#if __has_feature(objc_arc)
AudioServicesCreateSystemSoundID((__bridge CFURLRef)audioPath, &completeSound);
AudioServicesAddSystemSoundCompletion(completeSound, NULL, NULL, soundCompletionCallback, (__bridge_retained void*) cbDataCountNumber);
#else
AudioServicesCreateSystemSoundID((CFURLRef)audioPath, &completeSound);
AudioServicesAddSystemSoundCompletion(completeSound, NULL, NULL, soundCompletionCallback, (void*)([cbDataCountNumber retain]));
#endif
AudioServicesAddSystemSoundCompletion(completeSound, NULL, NULL, soundCompletionCallback, (void*)(cbDataCount-1));
AudioServicesPlaySystemSound(completeSound);
}

static void soundCompletionCallback(SystemSoundID ssid, void* data) {
int count = (int)data;
#if __has_feature(objc_arc)
NSNumber *cbDataCountNumber = (__bridge_transfer NSNumber *)data;
#else
NSNumber *cbDataCountNumber = [(NSNumber *)data release];
#endif
int count = [cbDataCountNumber intValue];
AudioServicesRemoveSystemSoundCompletion (ssid);
AudioServicesDisposeSystemSoundID(ssid);
if (count > 0) {