I'm coding a iOS-native extension to my OpenFl program that issues a notification. For some reason I simply can't convert the char* datatype from the parameter to the NSString that the alertBody property expects.
const void issueNotification (const char* message) {
UILocalNotification* localNotification;
localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:(1/6)];
//NSString* messageString = [NSString stringWithFormat:@"%c" , message]; // 1
//NSString* messageString = [NSString stringWithFormat:@"%s" , message]; // 2
//std::string messageString = std::string(message); // 3
//NSString *messageString = [NSString stringWithCString:message encoding:NSUTF8StringEncoding]; // 4
//NSString *messageString = [[NSString alloc] initWithCString:message encoding:NSUTF8StringEncoding]; // 5
NSString *messageString = @"AAAAA"; // 6
localNotification.alertBody = messageString;
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.timeZone = [NSTimeZone defaultTimeZone];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
1 gives me "warning: format specifies type 'int' but the argument has type 'const char *' [-Wformat]" when compiling.
2 compiles but the notification text shows up as something unintelligible (~0y or something like that).
3 won't compile.
4 and 5 will compile but the notifications won't fire.
6 works but then again I'm not using the parameter.
Any idea of what I'm doing wrong?
Thank you.