Ive been trying to register username "NataMio" into channels but its being registered under channels like ["global","NataMio"]. but it supposed to be ["NataMio"], anybody faced this issue ? on Android version of my application its registering it as ["NataMio"].
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation addUniqueObject:#"NataMio" forKey:#"channels"];
// [currentInstallation setDeviceTokenFromData:deviceToken];
[currentInstallation saveInBackgroundWithBlock:^(BOOL succeeded, NSError * _Nullable error) {
// code
}];
In your test, seems it contain "global" in default. So you can just set "channels" to ["NataMio"] directly.
Replace the following code:
[currentInstallation addUniqueObject:#"NataMio" forKey:#"channels"];
With:
currentInstallation.channels = #[#"NataMio"];
Related
Im trying to update a field in a PFInstallation object. My iOS Code is:
PFInstallation *installation = [PFInstallation currentInstallation];
installation[#"userId"] = #"none";
[installation saveEventually:^(BOOL suceeded, NSError *error){
if (suceeded) {
[PFUser logOutInBackgroundWithBlock:^(NSError *error){
if (!error) {
[self dismissViewControllerAnimated:YES completion:nil];
}
}];
}
else{
NSLog(#"Error Logging Out: %#", error);
}
}];
It use to work fine before, but for some reason using Parse Server I get the following error:
[Error]: at least one ID field (deviceToken, installationId) must be specified in this operation (Code: 135, Version: 1.12.0)
Anyone know how to fix this?
I'm trying to save multiple channels for the same user
But just keeps me first. Others do not save.
NSString *business =self.business.name;
NSArray *subscribedChannels = [PFInstallation currentInstallation].channels;
for (NSString *channel in subscribedChannels){
NSLog(#"Channel %# ",channel);
}
[currentInstallation addUniqueObject:business forKey:#"channels"];
NSLog(#"Business : %#",business );
[currentInstallation saveInBackground];
When I go to the table of parse web , it is only created the first channel.
What am I doing wrong?
My app was working fine. But from last hour it is crashing giving me a log:
Channel name must start with a letter: 2 (Code: 112, Version: 1.7.2)
I am using Parse push notification service and following code to subscribe a channel:
NSString *str =[[NSUserDefaults standardUserDefaults]objectForKey:#"userEmail"]; //asd#lop.com
str = [str stringByReplacingOccurrencesOfString:#"#"
withString:#"-"];
str = [str stringByReplacingOccurrencesOfString:#"."
withString:#"-"];
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation addUniqueObject:str forKey:#"channels"];
currentInstallation[#"user"] = [PFUser currentUser]; //app crashes here
[currentInstallation saveInBackground];
I haven't changed anything. I checked earlier versions of my code and they also crashing at same point. What is the issue i am unable to figure it out.
Your code seems fine and according to what you said that it used to be working I'd think you should try to uninstall/re-install the app on your device and try again.
I'm trying to add / remove channels from PFInstallation but I keep getting the same error message:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Operation is invalid after previous operation.'
My code:
NSString * channel=[NSString stringWithFormat:#"%#%#%#", city, #"_", self.titleLabel.text];
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
if([sender isOn]){
[currentInstallation addUniqueObject:channel forKey:#"channels"];
} else{
[currentInstallation removeObject:channel forKey:#"channels"];
}
[currentInstallation saveInBackground];
There is a bug in addUniqueObject method, when channels is nil.
You should add this before it.
if (currentInstallation.channels == nil)
{
currentInstallation.channels = [[NSArray alloc] init];
}
Also, you should use saveEventually instead of saveInBackGround.
This should be a bug in SDK.
I have an array of string's that I am trying to save to parse as the channels for push notifications. The array is correct, put I have no idea what is going on. Can anybody throw some light on this? Thanks.
Error:
Error: Bad channel name: TestString123 (Code: 112, Version: 1.1.30)
Code:
- (void)saveSelectedDepartmentsToParse:(NSMutableDictionary *)dictionary {
NSArray *array = [dictionary allKeysForObject:#"YES"];
NSLog(#"Array = %#", array);
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation addObjectsFromArray:array forKey:#"channels"];
[currentInstallation saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (error == nil) {
NSLog(#"Parse Save Succeeded");
}
else {
NSLog(#"Parse Save Failed, %#", error.localizedDescription);
}
}];
}
The reason is because Parse does not accept whitespaces or any special characters in the channels. After removing all white spaces and special characters, the operation succeeded.