Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new ProtocolPush and added OneSignal implementing it #153

Open
wants to merge 11 commits into
base: v4-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
Plugin-x
========
Plugin-x provides an easy way for developers to integrate various third party SDKs across different platforms with [cocos2d-x](https://github.com/cocos2d/cocos2d-x)
##### Plugin-x is now deprecated.

## Highlights
One unified API for all SDKs
* Ads
* Analytics
* IAP
* Social
Please use OneSignal from Cocos2d-x SDKBOX.

##Getting Started
* [Try the sample](https://github.com/cocos2d-x/plugin-x/wiki/Sample)
* [Documentation](http://www.cocos2d-x.org/wiki/Third_Party_SDK_Integration)
* Check out [wiki](https://github.com/cocos2d-x/plugin-x/wiki) for more info


##Update
* If you're looking for SDK integration solution for Chinese App Store, please consider using [AnySDK](http://www.anysdk.com)
http://www.sdkbox.com/plugins/onesignal
11 changes: 11 additions & 0 deletions plugins/OneSignal/proj.android/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="src" path="/libPluginProtocol"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="lib" path="sdk/OneSignalSDK.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
33 changes: 33 additions & 0 deletions plugins/OneSignal/proj.android/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>OneSignalCocos2dx</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
10 changes: 10 additions & 0 deletions plugins/OneSignal/proj.android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.onesignal.onesignalpush"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="19" />

</manifest>
90 changes: 90 additions & 0 deletions plugins/OneSignal/proj.android/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="libOneSignal" default="plugin-publish">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />

<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:

source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.

For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml

Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.

This file is an integral part of the build system for your
application and should be checked into Version Control Systems.

-->
<property file="ant.properties" />

<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>

<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.

This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).

This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />

<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>

<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />

<!-- Import the actual build file.

To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.

***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${plugin.dir}/tools/android/build_common.xml" />
</project>
20 changes: 20 additions & 0 deletions plugins/OneSignal/proj.android/proguard-project.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
16 changes: 16 additions & 0 deletions plugins/OneSignal/proj.android/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-19
android.library=true
android.library.reference.1=../../../protocols/proj.android
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/**
* Copyright 2015 OneSignal
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.cocos2dx.plugin;

import org.json.JSONObject;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

import com.onesignal.OneSignal;
import com.onesignal.OneSignal.GetTagsHandler;
import com.onesignal.OneSignal.IdsAvailableHandler;
import com.onesignal.OneSignal.NotificationOpenedHandler;

public class OneSignalPush implements InterfacePush, PluginListener {
private Context mContext;
private static OneSignalPush mInstance;

public OneSignalPush(Context context) {
mContext = context;
mInstance = this;
}

public void init(String googleProjectNumber, String appId) {
OneSignal.sdkType = "cocos2dx";
OneSignal.init((Activity)mContext, googleProjectNumber, appId, new NotificationOpenedHandler() {
public void notificationOpened(String message, JSONObject additionalData, boolean isActive) {
String curAdditionalData = null;
if (additionalData != null)
curAdditionalData = additionalData.toString();
PushWrapper.onDidReceiveRemoteNotification(mInstance, message, curAdditionalData, isActive);
}
});

PluginWrapper.addListener(this);
}

public void sendTag(String key, String value) {
OneSignal.sendTag(key, value);
}

public void deleteTag(String key) {
OneSignal.deleteTag(key);
}

public void getTags() {
OneSignal.getTags(new GetTagsHandler() {
@Override
public void tagsAvailable(JSONObject tags) {
try {
PushWrapper.onReceivedTags(mInstance, tags.toString());
} catch (Throwable t) {
t.printStackTrace();
}
}
});
}

public void getIds() {
OneSignal.idsAvailable(new IdsAvailableHandler() {
@Override
public void idsAvailable(String userId, String registrationId) {
try {
PushWrapper.onReceivedIds(mInstance, userId, registrationId);
} catch (Throwable t) {
t.printStackTrace();
}
}
});
}

@Override
public void onResume() {
OneSignal.onResumed();
}

@Override
public void onPause() {
OneSignal.onPaused();
}

@Override
public void onDestroy() {
}

@Override
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
return false;
}
}
31 changes: 31 additions & 0 deletions plugins/OneSignal/proj.ios/OneSignalPush/OneSignalPush.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright 2015 OneSignal
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import <Foundation/Foundation.h>
#import "InterfacePush.h"

@interface OneSignalPush : NSObject<InterfacePush> {

}

- (void) initWithAppId:(NSString*)appId autoRegister:(BOOL)autoRegister;
- (void) registerForPushNotifications;
- (void) sendTag:(NSString*)key value:(NSString*)value;
- (void) deleteTag:(NSString*)key;
- (void) getTags;
- (void) getIds;

@end
Loading