在应用程序中更改解析推送通知当前频道
Change Parse Push Notification Current Channel In App
我已使用 parse sdk 将工作代码添加到当前用户频道
但我想更改应用示例中的当前频道(在 Viewcontroller.m 中)
我的代码在这里
Appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
sleep(2);
[Parse setApplicationId:@"sdfsdfsdfsdfsdf"
clientKey:@"sdfsdfsdfsdf"];
// Register for Push Notitications
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
return YES;
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// Store the deviceToken in the current installation and save it to Parse.
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
[currentInstallation saveInBackground];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
}
我的观点controller.m文件
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
currentInstallation.channels = @[@"Second"];
[currentInstallation saveInBackground];
}
但不要将当前用户频道 Frist 更改为 Second。
我正在尝试一切但不改变我需要帮助。谢谢!
您是否尝试取消用户对旧频道的订阅,然后再订阅新频道?
这是我订阅和取消订阅频道的代码,它工作正常:
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation addUniqueObject:@"type1user" forKey:@"channels"];
[currentInstallation saveInBackground];
以及取消订阅和订阅第二个频道:
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation removeObject:@"type1user" forKey:@"channels"];
//subcribing to the second channel
[currentInstallation addUniqueObject:@"type2user" forKey:@"channels"];
[currentInstallation saveInBackground];
我已使用 parse sdk 将工作代码添加到当前用户频道 但我想更改应用示例中的当前频道(在 Viewcontroller.m 中)
我的代码在这里
Appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
sleep(2);
[Parse setApplicationId:@"sdfsdfsdfsdfsdf"
clientKey:@"sdfsdfsdfsdf"];
// Register for Push Notitications
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
return YES;
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// Store the deviceToken in the current installation and save it to Parse.
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
[currentInstallation saveInBackground];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
}
我的观点controller.m文件
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
currentInstallation.channels = @[@"Second"];
[currentInstallation saveInBackground];
}
但不要将当前用户频道 Frist 更改为 Second。 我正在尝试一切但不改变我需要帮助。谢谢!
您是否尝试取消用户对旧频道的订阅,然后再订阅新频道?
这是我订阅和取消订阅频道的代码,它工作正常:
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation addUniqueObject:@"type1user" forKey:@"channels"];
[currentInstallation saveInBackground];
以及取消订阅和订阅第二个频道:
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation removeObject:@"type1user" forKey:@"channels"];
//subcribing to the second channel
[currentInstallation addUniqueObject:@"type2user" forKey:@"channels"];
[currentInstallation saveInBackground];