Commit 51d47ed2 authored by Simon MacDonald's avatar Simon MacDonald
Browse files

Send notification event (iOS)

parent abaa5aeb
Loading
Loading
Loading
Loading
+12 −30
Changes for src/ios/PushPlugin.m: 12 added lines, 30 removed lines.
Original line number Diff line number Diff line
@@ -210,45 +210,27 @@
    if (notificationMessage)
    {
        NSMutableDictionary* message = [NSMutableDictionary dictionaryWithCapacity:4];
//        [message setObject:token forKey:@"registrationId"];
        
        for(id key in notificationMessage) {
            id value = [notificationMessage objectForKey:key];
            if ([value isEqualToString:@"alert"]) {
                [message setObject:value forKey:@"alert"];
        id aps = [notificationMessage objectForKey:@"aps"];

        for(id key in aps) {
            NSLog(@"Push Plugin key: %@", key);
            id value = [aps objectForKey:key];
            
            if ([key isEqualToString:@"alert"]) {
                [message setObject:value forKey:@"message"];
            }
            if ([value isEqualToString:@"title"]) {
            if ([key isEqualToString:@"title"]) {
                [message setObject:value forKey:@"title"];
            }
            if ([value isEqualToString:@"badge"]) {
                [message setObject:value forKey:@"badge"];
            if ([key isEqualToString:@"badge"]) {
                [message setObject:value forKey:@"count"];
            }
            if ([value isEqualToString:@"sound"]) {
            if ([key isEqualToString:@"sound"]) {
                [message setObject:value forKey:@"sound"];
            }
        }
        
        /*
        NSMutableString *jsonStr = [NSMutableString stringWithString:@"{"];

        [self parseDictionary:notificationMessage intoJSON:jsonStr];

        if (isInline)
        {
            [jsonStr appendFormat:@"foreground:\"%d\"", 1];
            isInline = NO;
        }
		else
            [jsonStr appendFormat:@"foreground:\"%d\"", 0];

        [jsonStr appendString:@"}"];

        NSLog(@"Msg: %@", jsonStr);

        NSString * jsCallBack = [NSString stringWithFormat:@"%@(%@);", self.callback, jsonStr];
        [self.webView stringByEvaluatingJavaScriptFromString:jsCallBack];
         */
        
        // send notification message
        CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:message];
        [pluginResult setKeepCallbackAsBool:YES];