Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 16    Views: 300

Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
10/13/14 02:00 AM (9 years ago)

How Do I Integrate Parse For iOS 8?

Attempting to integrate Parse Push Notification into my app for iOS 8, but having a slight issue with where to ad the last bit of code. Can anyone help? I need to add this but not sure where as I get an error when I add to my appdelegate.m file: - (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]; } Can someone tell me where I add this code as, the line: - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { causes an error.
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
10/13/14 02:12 AM (9 years ago)
Hi Dragon, You probably are pasting a method into a class that already has that method declared. -(void)application, specifically. Just copy the code from inside that method (your parse device token stuff) into your existing one. Edit: Also sent you a private message. Headed to bed, but good luck! Cheers, David Van Beveren http://btmods.com/chat ^ Chat with other BT members live! http://btmods.com/hire ^ Hire MrDavid for one of his services!
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
10/13/14 02:39 AM (9 years ago)
Thanks Man! Will check it out.
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
10/13/14 03:27 AM (9 years ago)
Still having issues.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
10/13/14 03:47 AM (9 years ago)
I just finished this... Let me gather my thoughts here. Ok, for 'the most part' you'll follow along the Parse instructions, but with a few minor changes for steps 7,8 & 9... 1) Create your certificate requests for Developer. Do the Release later, but for now just Dev. 2) Create your certificates in your Apple Dev Account. Download a copy. Double click to add to your keyManager. 3) Select and export your certificate (from keymgr). Don't add a password, but you'll need to use yours. 4) Upload the cert to your parse account for the project. 5) Add all the required frameworks. Although most are already there, not *all* of them are. 6) In 'didFinishLaunchWithOptions', *just before* 'makeKeyAndVisible' at the end of the method, paste your AppID/clientKey line. Also paste that "if App responds to selector" code. 7) REPLACE the 'didReceiveRemoteNotification' method with the Parse method. 8) REPLACE the 'didRegisterForRemoteNotificationsWithDeviceToken' with the parse method. 9) Make the changes suggested by Chris1 in this post: https://www.buzztouch.com/forum/thread.php?tid=DA308929DBC29D1DB83B7A8 and if I haven't forgotten anything, that *should* work. Cheers! -- Smug Edit: And don't forget to set your project to do push in the control panel 'core' settings!
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
10/13/14 04:17 AM (9 years ago)
Thank Smug, this is actually a massive help and will try shortly. Much appreciated!
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
10/13/14 04:54 AM (9 years ago)
Hi Smug I have loads of errors now, struggling. My problem is when I have to replace the BT code with the Parse, causing me all sorts of issues. Just don't get it what's happening.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
10/13/14 05:10 AM (9 years ago)
Well, just do one step at a time. Most of the stuff can be done pretty much straight off the parse 'quickstart' instructions... I forgot to mention adding: '#import <Parse/Parse.h>' along with the other header includes, but it's a biggie, so if you haven't done that, it needs to be done. paste those 2 bits of code just before the 'makeKeyAndVisible' statement in the 'didFinishLaunchingWithOptions' method, somewhere in the neighborhood of line 159-ish: [Parse setApplicationId:@"xxxxxxx" clientKey:@"xxxxxxx"]; // Register for Push Notitications, if running iOS 8 if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) { Parse Stuff } else { More Parse Stuff } The other two methods are 'completely replaced' by the parse methods. You can either delete them, or comment the methods out, but you can't have duplicates; that causes problems: - (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]; } If you get all this stuff from the app parse quickstart, they've already included the correct key and client ID for you; you should only need to copy/paste. And then there is that code that chris1 provided; that's a dealbreaker as well. Follow his instructions and you'll be fine. But if you're getting errors, it's either the #import parse.h wasn't imported, you have duplicate methods that need to be addressed, or you added/dropped a bracket somewhere. Hope this helps! Cheers! -- Smug
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
10/13/14 05:19 AM (9 years ago)
Sorry Smug but your guide has confused me more. You have asked me to add these two bits of code: [Parse setApplicationId:@"xxxxxxx" clientKey:@"xxxxxxx"]; // Register for Push Notitications, if running iOS 8 if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) { Parse Stuff } else { More Parse Stuff } But the '// Register for Push Notitications, if running iOS 8' part I thought was to be added and replace else where and not where you have it. I have added but still getting errors. Confused!
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
10/13/14 05:23 AM (9 years ago)
Must be doing something wrong, as I'm getting loads of errors. Is there any other bits of code that should be deleted from the app delegate to make this work, as when I replace the BT code with the Parse code, I get a number of errors. And I have added Chris1 extras on top. Banging my head.
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
10/13/14 05:35 AM (9 years ago)
Smug Do you have any screen shots of your app delegate, that will help me?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
10/13/14 08:05 AM (9 years ago)
Check this out, and I hope it helps. https://dl.dropboxusercontent.com/u/115208762/ParseQuickie.pdf It doesn't cover *everything*, but it covers the important basics. Cheers! -- Smug
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
10/13/14 09:14 AM (9 years ago)
Hi Smug your guide has really helped. However I still have 2 errors, these are in my AppDelegate.m file line 844 //if we have a token, and a register it... line 844 (error 'if') if([deviceToken length] > 1 && [[self.rootApp registerForPushURL] length] > 1){ and also line 922 //didReceiveRemoteNotification.. line 922 (error '-') -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{ [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"didReceiveRemoteNotification %@", @""]]; Can you please advise?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
10/13/14 09:16 AM (9 years ago)
What does the error say? Cheers! -- Smug Do you have the right number of brackets? Did you add the additional SDK's ?
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
10/13/14 09:49 AM (9 years ago)
Yes! to SDK. I added the errors above and the line and in brackets what the error actually is. ine 844 line 844 (error Expected Identifier or '(' - referring to 'if') //if we have a token, and a register it... if([deviceToken length] > 1 && [[self.rootApp registerForPushURL] length] > 1){ and also line 922 line 922 (error Duplication declaration of method 'application:didReceiveRemote Notification:' //didReceiveRemoteNotification.. -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{ [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"didReceiveRemoteNotification %@", @""]];
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
10/13/14 10:05 AM (9 years ago)
Hi Smug I have Kittsy helping me right now. Once sorted I to will create a guide.
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
10/13/14 11:22 AM (9 years ago)
Hi Smug Kittsy has helped me get it going, there were a number of code I needed to delete from my app delegate file that I wasn't told about. I'm going to put together a guide for iOS Parse Notifications in a few days for novices like me who do not know how to code. But a big thanks Smug as your first part of your guide helped get the code into my app.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.