[GUIDE] Cocos2d-x 3.8 + Parse push notifications for Android & IOS

Hello guys,
I was able to integrate Parse push notification into Cocos2d-x, so I would like share instruction with you in case someone would need this.

Would appreciate if someone can help extend it to make it working with passed URI parameters from notifications.

So there is instructions for Android in Android-studio:
(Original parse manual)
https://parse.com/apps/quickstart#parse_push/android/native/existing

  1. Modify your gradle.build add as described in parse DOCS:

    dependencies {

    //Add this depndencies
    compile ‘com.parse.bolts:bolts-android:1.+’
    compile ‘com.parse:parse-android:1.+’
    }

  2. Modify Androidmanifest file as described in DOC, don’t forget to put your application package name:

     <!--
       IMPORTANT: Change "com.parse.starter" to match your app's package name.
     -->
     <category android:name="com.parse.starter" />
    
  3. Add extra permissions as described in DOC:


  4. Now there is tricky part, to work properly with Parse on Android you should create your own class and initialize parse inside(parse requiring to be initialized in Application class)
    There is mine class MyApplication created under package org.cocos2dx.cpp:

    package org.cocos2dx.cpp;
     
     import android.app.Application;
     
     import com.parse.Parse;
     import com.parse.ParseInstallation;
     import com.parse.ParsePush;
     
     public class MyApplication extends Application
     {
         @Override
         public void onCreate()
         {
             super.onCreate();
     
             try {
                 Parse.initialize(this, "YOUR_API_KEY", "YOUR_SECRET_KEY");
                 ParseInstallation.getCurrentInstallation().saveInBackground();
    

    //There I’m adding dummy channel
    ParsePush.subscribeInBackground(“Giants”);
    ParsePush push = new ParsePush();
    } catch (Exception e) {
    e.printStackTrace();
    }

         }
     
     }
    
  5. Now modify your Android manifest file <aplication> tag, I have added android:name parameter which pointing to my created class:

Done, now it should work :slight_smile: Have a try to send from Parse GUI push notification

7 Likes

Just in case:D parse no more exists:D

That is not true, Parse.com service has been shut down, but they released the parse-server as open source, so you can still deploy it on your own infrastructure or wherever you want.

That said, has anyone used Parse as backend in Cocos other than just the push notifications? seems like an interesting approach, the thing is there isn’t a C++ SDK, so it would have to be using http requests to the REST API I guess.

Has anyone tried/ done this?