Discussion Forums  >  Uncategorized

Replies: 39    Views: 697

LoglineEngine
I hate code!
Profile
Posts: 65
Reg: Sep 24, 2011
LA
650
10/09/11 04:06 PM (12 years ago)

Parse.com ==> What File is Activity Class In? Adding Code for Push Notification

Hi, I am using parse.com for push notifications. Also having trouble with these steps: ------- 1) Call Parse.initialize from your onCreate methods to set your application id and client key: public void onCreate() { Parse.initialize(this, customcode, customcode); } ---------- 2) You will also have to add import statements: import com.parse.Parse; import com.parse.ParseObject; ========== I have been told the code should be added to the Activity Class. But I have no idea where that is. What file name should I be adding this to? I don't know where onCreate methods are located. This is the last step before I can test the push notifications. Will let you guys know once it works. Thanks. Patrice
 
ThomasB
Lost but trying
Profile
Posts: 162
Reg: Jun 23, 2011
Palo Alto
3,270
like
10/09/11 04:49 PM (12 years ago)
@Patrice, we hadn't tried Parse for push notifications yet. Very interested how it comes out. There are several threads in the forum discussing integration of other push notification services, such as Urban Airship. You might try looking at those for hints how to do it for Parse. Try searching on push in forum.
 
LoglineEngine
I hate code!
Profile
Posts: 65
Reg: Sep 24, 2011
LA
650
like
10/09/11 05:42 PM (12 years ago)
Hi Thomas, I did actually. David gave a n answer on where to put the code, but wasn't specific on where the code/file was located, or what the name of the file was. I read with Urban Airship that the user has to download an additional file in order to receive the push notifications. That seems like too much to ask a user, so that's why I'm trying Parse. I've figured all the other steps to integration, except this one.,
 
shockme66
Apple Fan
Profile
Posts: 81
Reg: Sep 12, 2011
Easton PA
1,010
like
10/10/11 10:17 AM (12 years ago)
Patrice - Please update this thread when you figure it out. I would love to be able to add push notifications to may app and have been looking at Parse as well. Thanks.
 
LoglineEngine
I hate code!
Profile
Posts: 65
Reg: Sep 24, 2011
LA
650
like
10/10/11 11:03 AM (12 years ago)
Yes, I will, with specifics on how I implemented. But I'm currently at a standstill until I can get help with this part of it. :o(
 
shockme66
Apple Fan
Profile
Posts: 81
Reg: Sep 12, 2011
Easton PA
1,010
like
10/10/11 11:08 AM (12 years ago)
Are you working on a Adroid or iOS project. I am working on a iOS and so far got the test to work, I am uploaded the iOS cert to the parse site now and going to do a test push notification. I'll let you know how it works out.
 
LoglineEngine
I hate code!
Profile
Posts: 65
Reg: Sep 24, 2011
LA
650
like
10/10/11 12:13 PM (12 years ago)
Hi, I'm doing Android with a 1.4 project.
 
shockme66
Apple Fan
Profile
Posts: 81
Reg: Sep 12, 2011
Easton PA
1,010
like
10/10/11 01:05 PM (12 years ago)
ohh ok, Like I said I am doing a iOS project and think I have it working. I just need to test on the device when I get home. Sorry, I wish I could help on the Android side.
 
LoglineEngine
I hate code!
Profile
Posts: 65
Reg: Sep 24, 2011
LA
650
like
10/10/11 02:22 PM (12 years ago)
That's okay. I'll figure something out. Let me know how it goes. Apparently you can run the notifications through the simulator with Android to test, but not with iOS.
 
shockme66
Apple Fan
Profile
Posts: 81
Reg: Sep 12, 2011
Easton PA
1,010
like
10/13/11 06:29 AM (12 years ago)
Patrice, I have my iOS app working with Parse and got it updated via the apple store and just did a live test. All is working. Let me know if I can help in anyway. Thanks.
 
LoglineEngine
I hate code!
Profile
Posts: 65
Reg: Sep 24, 2011
LA
650
like
10/13/11 09:13 AM (12 years ago)
Awesome. I actually deleted my file with all the parse updates and downloaded a new file as I was stuck. If I were to try and integrate again, I would still need help with the part listed in my original thread. Is that something you would know about?
 
shockme66
Apple Fan
Profile
Posts: 81
Reg: Sep 12, 2011
Easton PA
1,010
like
10/13/11 09:18 AM (12 years ago)
I think the implementation is not the same for android as it is for iOS. For iOS it is the following: 1. Create a Push Cert on the itunes connect site and enable push notificatons. 2. Add the parse framework to your project. 3. Add the code snippets parse.com provides you. That's it. Let me know if this is the same for android.
 
LoglineEngine
I hate code!
Profile
Posts: 65
Reg: Sep 24, 2011
LA
650
like
10/13/11 10:20 AM (12 years ago)
Here are the steps for Android: ------ 1. Download the SDK SDK files for existing Android projects (.jar) 2. Install the SDK Import the jar into your existing Android project by dragging it into your assets folder. Right click the jar file and select Build Path → Add to build path. Call Parse.initialize from your onCreate methods to set your application id and client key: public void onCreate() { Parse.initialize(this, W0ANFZC3QolDK627OopO2uatVwl1JdPfdDroc2Cz, Vtn6ojRp2yxFQjVdpoEHltEdnI8JgRHsJwqgFx8S); } You will also have to add import statements: import com.parse.Parse; import com.parse.ParseObject; Eclipse should prompt you automatically to do this. Your app must request the INTERNET permission, if it isn't doing so already. Add this line: <uses-permission android:name=android.permission.INTERNET /> right before the </manifest> closing tag in your AndroidManifest.xml. 3. Test the SDK After installing the SDK, copy and paste this code into your app, for example in onCreate: ParseObject testObject = new ParseObject(TestObject); testObject.put(foo, bar); testObject.saveInBackground(); Compile and run your app. A new object of class TestObject will be sent to our servers and saved. When you're ready, click the button below to test if your data was sent. -------- There are also additional steps for using PUSH feature: --- Adding Push To Your App Push notifications let your application notify a user of new messages or events even when the user is not actively using your application. On Android devices, when a device receives a push notification, your application's icon and a message appear in the status bar. When the user taps the notification, they are sent to your application. Notifications can be broadcast to all users, such as for a marketing campaign, or sent to just a subset of users, to give personalized information. The Parse library provides push notifications by running a background service that keeps an internet connection to the Parse push servers. This method of push notification is compatible back to Android 1.5 and does not require an active Google account on the phone. To use push notifications, your application must register this background service. Add the following XML to your AndroidManifest.xml file immediately before the closing </application> tag: <service android:name=com.parse.PushService /> <receiver android:name=com.parse.ParseBroadcastReceiver> <intent-filter> <action android:name=android.intent.action.BOOT_COMPLETED /> <action android:name=android.intent.action.USER_PRESENT /> </intent-filter> </receiver> Next, your application must have the permissions needed to show a notification. Make sure that these permissions are present in your AndroidManifest.xml file, typically immediately before the closing </manifest> tag: <uses-permission android:name=android.permission.INTERNET /> <uses-permission android:name=android.permission.RECEIVE_BOOT_COMPLETED /> <uses-permission android:name=android.permission.VIBRATE /> Finally, your application needs to inform the Parse servers that it is ready for notifications. The simplest way to get started is to subscribe your application to the global broadcast channel, represented by the empty string. Add this line of code anywhere within a valid activity, such as the onCreate method of your main activity: PushService.subscribe(this, , YourActivity.class); At this point, you're ready to send push notifications. From the Push Notifications tab, you can use the provided text box to all of your app's users. Unlike iOS, Android push notifications do work from the emulator, so you can use the emulator to test out push.
 
shockme66
Apple Fan
Profile
Posts: 81
Reg: Sep 12, 2011
Easton PA
1,010
like
10/13/11 10:32 AM (12 years ago)
It seems similar, but I just don't have the android experience to understand you problem. I would try using the chat on the parse.com site, they don't always seem to be around, but when they are they may be able to help. FYI - I found some erros on the parse documents for iOS that they changed due to my questions; it may be the same situation for android.
 
LoglineEngine
I hate code!
Profile
Posts: 65
Reg: Sep 24, 2011
LA
650
like
10/13/11 10:50 AM (12 years ago)
They told me it takes some programming and that new coding needs to be in Activity class. But I have no idea where that is. So I'll just move on. Will look for another push company that is more user-friendly to non-programmers. But thanks anyway. :o)
 
shockme66
Apple Fan
Profile
Posts: 81
Reg: Sep 12, 2011
Easton PA
1,010
like
10/13/11 10:52 AM (12 years ago)
I agree, seems a little crazy on the ardoid side using parse. Did you check urban airship, they offer more services than just push. I should of used them, maybe on my next revision.
 
LoglineEngine
I hate code!
Profile
Posts: 65
Reg: Sep 24, 2011
LA
650
like
10/13/11 10:56 AM (12 years ago)
I'll look into them. But their service is not free.
 
shockme66
Apple Fan
Profile
Posts: 81
Reg: Sep 12, 2011
Easton PA
1,010
like
10/13/11 10:57 AM (12 years ago)
I think 1MM messages a month is free, there expanded service is not free.
 
LoglineEngine
I hate code!
Profile
Posts: 65
Reg: Sep 24, 2011
LA
650
like
10/13/11 10:59 AM (12 years ago)
Oh, okay.
 
anthonyangel89
I hate code!
Profile
Posts: 7
Reg: Apr 03, 2011
London
1,270
like
10/16/11 06:56 AM (12 years ago)
I'm also interested in this, any help on the creating a page to allow users to subscribe to parse channels (https://www.parse.com/docs/ios_guide#push-channels) would be amazing as I'd like to be able to target messages
 
ridgerock
Veteran developer
Profile
Posts: 183
Reg: May 19, 2011
Louisville
1,830
like
10/18/11 11:24 AM (12 years ago)
Hey Shockme66 I have been kiling myslef trying to get Parse to work. What files are you pasting the Parse code in?
 
shockme66
Apple Fan
Profile
Posts: 81
Reg: Sep 12, 2011
Easton PA
1,010
like
10/19/11 04:23 PM (12 years ago)
There are three files to past code into: 1. Go to folder BT_Config and you need past code in both the .h and .m delagate files 2. Go to BT_Object (I think that's the name) look for the main.m file and pase the code that parse tells you to for the main function.
 
Mackimack
Apple Fan
Profile
Posts: 481
Reg: Dec 30, 2010
Sweden
14,310
like
11/03/11 02:40 AM (12 years ago)
@Shockme66 Do have a guide for how to implement Parse into Xcode project? I have try it but it will not work for me.
 
shockme66
Apple Fan
Profile
Posts: 81
Reg: Sep 12, 2011
Easton PA
1,010
like
11/03/11 05:40 AM (12 years ago)
I don't have a guide, but the parse guide is really good. There were some errors in it but I contacted them and they fixed it. What issues are you having?
 
Chacka7
buzztouch Evangelist
Profile
Posts: 113
Reg: Oct 29, 2011
London
1,330
like
01/01/12 11:20 AM (12 years ago)
I am going mental trying to do this! :(
 
MacApple
Apple Fan
Profile
Posts: 4674
Reg: Oct 25, 2010
USA
61,140
like
01/01/12 07:42 PM (12 years ago)
@Chacka7 - Good number, the 7 in your name that is, some say magnificent. Anyway..... Ditched Appoxee this morning and started to implement Parse, looks slicker at first glance. Just got the test object firing and try the final part tomorrow. You make any progress, will post back tomorrow.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
01/01/12 07:57 PM (12 years ago)
If you've got a server, why not go straight to the open source - c2dm? It's what all these services use to an extent and it's completely free. Capped at 250,000 messages a day, but you just have to ask to have the cap lifted! It's a stiff learning curve, but it gives the flexibility to do whatever you want with no fees. @MacApple - Are you flirting with a cartoon avatar? hmmmmmm?
 
MacApple
Apple Fan
Profile
Posts: 4674
Reg: Oct 25, 2010
USA
61,140
like
01/01/12 08:33 PM (12 years ago)
Ah, OK. You using c2dm successfully? Would love to know more. 7 is a good number, you know it is!
 
Chacka7
buzztouch Evangelist
Profile
Posts: 113
Reg: Oct 29, 2011
London
1,330
like
01/02/12 06:02 AM (12 years ago)
Thanks MacApple - Yes, 7 is a great number! ;-) Hopefully it will bring me some luck and I can nail this today!! Will keep you guys posted on my progress.. @anthonyangel89 - Have you managed to create a page to allow users to subscribe to parse channels (https://www.parse.com/docs/ios_guide#push-channels) - Really want to incorporate this feature when I get this running..
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
01/02/12 07:17 AM (12 years ago)
King Kenny, Keegan, Mcmannaman, Beardsley, Suarez... Number 7 ain't so bad! (real football, not chasing an egg football :-)). I've got a basic c2dm application working, not in bt though, but I needed the help of a friend to get the server set up and talking to the app. Still can't understand that part.
 
MacApple
Apple Fan
Profile
Posts: 4674
Reg: Oct 25, 2010
USA
61,140
like
01/02/12 07:26 AM (12 years ago)
That was indeed my 7 reference. Was thinking along the lines of Henrik Larsson! King Kenny works though. Back to Parse errors, be back soon.
 
Chacka7
buzztouch Evangelist
Profile
Posts: 113
Reg: Oct 29, 2011
London
1,330
like
01/03/12 11:32 AM (12 years ago)
I have this working now on my IOS test device now!! Fantastic! :) One quick question if anyone knows.. I see that the messages were initially coming up in 'banner' format (small message across the top of screen) and not an 'alert' (big message in middle of screen). Now, I see that this can be amended in the users individual settings for notifications (and perhaps I already had my individual settings amended to 'banner'). But ideally, I would like all the end users to receive this as an alert as the default without having to amend in settings.. This is the code supplied by Parse to register for remote notifications but I cannot see any reason here as to why it may default to banner and not alert.. [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge| UIRemoteNotificationTypeAlert| UIRemoteNotificationTypeSound]; Do you think this is just due to the settings on my individual device (IPhone 4) and should these default as proper alert messages on the end users phone? Or is there anything I need to do with the code to ensure that alert (and not banner) messages are the default? Thanks :)
 
anthonyangel89
I hate code!
Profile
Posts: 7
Reg: Apr 03, 2011
London
1,270
like
01/09/12 06:12 AM (12 years ago)
Hi Chacka7, I haven't managed to get that feature working for subscriptions to specific channels. (I was hoping that someone better than me would figure it out and post a guide!)
 
NDHMT
Apple Fan
Profile
Posts: 10
Reg: Aug 02, 2011
Maysville
100
like
01/12/12 09:25 PM (12 years ago)
@shockme66 or anyone that can help I am having trouble. I really want to use Parse.com for my push notifications. I did everything parse said on the quick start. But right now, I am getting stuck on a black screen. And also, i do not know where to put the two sections of code for the test. I have tried to restart my computer but still no luck! Please Help!!!!
 
shockme66
Apple Fan
Profile
Posts: 81
Reg: Sep 12, 2011
Easton PA
1,010
like
01/13/12 05:05 AM (12 years ago)
Post what you can, and I'll see if I can help.
 
MacApple
Apple Fan
Profile
Posts: 4674
Reg: Oct 25, 2010
USA
61,140
like
01/13/12 06:38 AM (12 years ago)
I'll stick on here, off to office but will be back around 4pm EST. I ran through the process twice before I got it right, stick in.
 
NDHMT
Apple Fan
Profile
Posts: 10
Reg: Aug 02, 2011
Maysville
100
like
01/13/12 09:48 AM (12 years ago)
I don't know where to put this: PFObject *testObject = [PFObject objectWithClassName:@TestObject]; [testObject setObject:@bar forKey:@foo]; [testObject save];
 
NDHMT
Apple Fan
Profile
Posts: 10
Reg: Aug 02, 2011
Maysville
100
like
01/13/12 10:13 AM (12 years ago)
I don't know where to put this: PFObject *testObject = [PFObject objectWithClassName:@TestObject]; [testObject setObject:@bar forKey:@foo]; [testObject save];
 
NDHMT
Apple Fan
Profile
Posts: 10
Reg: Aug 02, 2011
Maysville
100
like
01/13/12 10:19 AM (12 years ago)
I re-downloaded my source code from BT and just restarted and followed Parse step by step and I am still getting a black screen on startup. I can't figure it out.
 
jonathanmiami
I hate code!
Profile
Posts: 20
Reg: Dec 09, 2010
Miami
200
like
04/05/12 03:54 PM (12 years ago)
I have follow all the steps and my app runs fine but still does not show any push notifications or errors anywhere...please help!!
 

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.