I need to get which topics the user subscribe in my app.
I found this question for Android. And try to copy this to Objective-C, but I get an exception:
-(void)getUserTopicSubscribeWithToken
{
NSString *token = [[FIRInstanceID instanceID] token];
NSString *urlString = [NSString stringWithFormat:@"https://iid.googleapis.com/iid/info/<%@>?details=true",token];
NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setHTTPMethod:@"GET"];
//set the content type to JSON
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"Authorization" forKey:@"FIREBASE_KEY"];
[request setURL:url];
NSError *error = nil;
NSHTTPURLResponse *responseCode = nil;
NSData *oResponseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&responseCode error:&error];
NSString * topics = [[NSString alloc] initWithData:oResponseData encoding:NSUTF8StringEncoding];
NSLog(@"%@",topics);
}
what can be the problem ?