Icon for push notification?
To Accomplish this firstly you need to goto your Info.Plist file and add some properties in Icon-File that is
<key>CFBundleIcons</key> <dict> <key>CFBundleAlternateIcon</key> <dict> <key>first_icon</key> <dict> <key>CFBundleIconFile</key> <array> <string>first_icon.png</string> </array> </dict> <key>second_icon</key> <dict> <key>CFBundleIconFile</key> <array> <string>second_icon.png</string> </array> </dict> </dict> <key>CFBundlePrimaryIcon</key> <dict> <key>CFBundleIconFiles</key> <array> <string></string> </array> <key>UIPrerenderedIcon</key> <false/> </dict> <key>UINewsstandIcon</key> <dict> <key>CFBundleIconFiles</key> <array> <string></string> </array> <key>UINewsstandBindingType</key> <string>UINewsstandBindingTypeMagazine</string> <key>UINewsstandBindingEdge</key> <string>UINewsstandBindingEdgeLeft</string> </dict> </dict>
Now you need to configure settings in your AppDelegate
file
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ NSDictionary *notificationData = [[PushNotificationManager pushManager] getCustomPushDataAsNSDict:userInfo]; NSString * notiIcon = [notificationData objectForKey:@"newIcon"]; if([notiIcon isEqualToString:@"nil"]) notiIcon = nil; NSLog(@"icon is: %@", notiIcon); [[UIApplication sharedApplication] setAlternateIconName:notiIcon completionHandler:^(NSError * _Nullable error) { NSLog(@"Set icon error = %@", error.localizedDescription); }]; });
now from any dashboard you send the notification to the app goto that and there would be and option named Action
or something like send Custom data
send a key-value
pair in code we are using key 'newIcon' so send it like that
{"newIcon":"first_icon"}
now when you'll send the notification with iconName that will appear.
This will Work..