diff --git a/README.md b/README.md index e98862d3..43ca2a04 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/plugins/OneSignal/proj.android/.classpath b/plugins/OneSignal/proj.android/.classpath new file mode 100644 index 00000000..63742598 --- /dev/null +++ b/plugins/OneSignal/proj.android/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/plugins/OneSignal/proj.android/.project b/plugins/OneSignal/proj.android/.project new file mode 100644 index 00000000..60dc8481 --- /dev/null +++ b/plugins/OneSignal/proj.android/.project @@ -0,0 +1,33 @@ + + + OneSignalCocos2dx + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/plugins/OneSignal/proj.android/AndroidManifest.xml b/plugins/OneSignal/proj.android/AndroidManifest.xml new file mode 100644 index 00000000..615a88d3 --- /dev/null +++ b/plugins/OneSignal/proj.android/AndroidManifest.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/plugins/OneSignal/proj.android/build.xml b/plugins/OneSignal/proj.android/build.xml new file mode 100644 index 00000000..8bd76451 --- /dev/null +++ b/plugins/OneSignal/proj.android/build.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/OneSignal/proj.android/proguard-project.txt b/plugins/OneSignal/proj.android/proguard-project.txt new file mode 100644 index 00000000..f2fe1559 --- /dev/null +++ b/plugins/OneSignal/proj.android/proguard-project.txt @@ -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 *; +#} diff --git a/plugins/OneSignal/proj.android/project.properties b/plugins/OneSignal/proj.android/project.properties new file mode 100644 index 00000000..7db407db --- /dev/null +++ b/plugins/OneSignal/proj.android/project.properties @@ -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 diff --git a/plugins/OneSignal/proj.android/sdk/OneSignalSDK.jar b/plugins/OneSignal/proj.android/sdk/OneSignalSDK.jar new file mode 100644 index 00000000..e28725de Binary files /dev/null and b/plugins/OneSignal/proj.android/sdk/OneSignalSDK.jar differ diff --git a/plugins/OneSignal/proj.android/src/org/cocos2dx/plugin/OneSignalPush.java b/plugins/OneSignal/proj.android/src/org/cocos2dx/plugin/OneSignalPush.java new file mode 100644 index 00000000..c1cef24f --- /dev/null +++ b/plugins/OneSignal/proj.android/src/org/cocos2dx/plugin/OneSignalPush.java @@ -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; + } +} \ No newline at end of file diff --git a/plugins/OneSignal/proj.ios/OneSignalPush/OneSignalPush.h b/plugins/OneSignal/proj.ios/OneSignalPush/OneSignalPush.h new file mode 100644 index 00000000..1025195c --- /dev/null +++ b/plugins/OneSignal/proj.ios/OneSignalPush/OneSignalPush.h @@ -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 +#import "InterfacePush.h" + +@interface OneSignalPush : NSObject { + +} + +- (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 diff --git a/plugins/OneSignal/proj.ios/OneSignalPush/OneSignalPush.m b/plugins/OneSignal/proj.ios/OneSignalPush/OneSignalPush.m new file mode 100644 index 00000000..5bf6d58a --- /dev/null +++ b/plugins/OneSignal/proj.ios/OneSignalPush/OneSignalPush.m @@ -0,0 +1,141 @@ +/** + * 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 +#import + +#import "PushWrapper.h" + +#import +#import "OneSignalPush.h" + + +OneSignalPush* oneSignalPush; +OneSignal* oneSignal; + +NSString* launchMessage; +NSDictionary* launchAdditionalData; +BOOL launchIsActive; + +BOOL initCalled = false; + + +NSString* dictionaryToJsonString(NSDictionary* dictionaryToConvert) { + if (!dictionaryToConvert) + return nil; + NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dictionaryToConvert options:0 error:nil]; + return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; +} + +void processNotificationOpened() { + [PushWrapper onDidReceiveRemoteNotification:oneSignalPush message:launchMessage additionalData:dictionaryToJsonString(launchAdditionalData) isActive:launchIsActive]; +} + +void initOneSignalObject(NSDictionary* launchOptions, NSString* appId, BOOL autoRegister) { + if (oneSignal == nil) { + [OneSignal setValue:@"coscos2dx" forKey:@"mSDKType"]; + oneSignal = [[OneSignal alloc] initWithLaunchOptions:launchOptions appId:appId handleNotification:^(NSString* message, NSDictionary* additionalData, BOOL isActive) { + launchMessage = message; + launchAdditionalData = additionalData; + launchIsActive = isActive; + + if (initCalled) + processNotificationOpened(); + } autoRegister:autoRegister]; + } +} + +@implementation UIApplication(OneSignalCocos2dxPush) + +static void injectSelector(Class newClass, SEL newSel, Class addToClass, SEL makeLikeSel) { + Method newMeth = class_getInstanceMethod(newClass, newSel); + IMP imp = method_getImplementation(newMeth); + const char* methodTypeEncoding = method_getTypeEncoding(newMeth); + + BOOL successful = class_addMethod(addToClass, makeLikeSel, imp, methodTypeEncoding); + if (!successful) { + class_addMethod(addToClass, newSel, imp, methodTypeEncoding); + newMeth = class_getInstanceMethod(addToClass, newSel); + + Method orgMeth = class_getInstanceMethod(addToClass, makeLikeSel); + + method_exchangeImplementations(orgMeth, newMeth); + } +} + ++ (void)load { + method_exchangeImplementations(class_getInstanceMethod(self, @selector(setDelegate:)), class_getInstanceMethod(self, @selector(setOneSignalCocos2dxDelegate:))); +} + +static Class delegateClass = nil; + +- (void) setOneSignalCocos2dxDelegate:(id)delegate { + if(delegateClass != nil) + return; + delegateClass = [delegate class]; + + injectSelector(self.class, @selector(oneSignalApplication:didFinishLaunchingWithOptions:), + delegateClass, @selector(application:didFinishLaunchingWithOptions:)); + [self setOneSignalCocos2dxDelegate:delegate]; +} + +- (BOOL)oneSignalApplication:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { + if ([launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey] != nil) + initOneSignalObject(launchOptions, nil, true); + + if ([self respondsToSelector:@selector(oneSignalApplication:didFinishLaunchingWithOptions:)]) + return [self oneSignalApplication:application didFinishLaunchingWithOptions:launchOptions]; + return YES; +} + +@end + +@implementation OneSignalPush + +- (void) initWithAppId:(NSString*)appId autoRegister:(BOOL)autoRegister { + oneSignalPush = self; + initCalled = true; + initOneSignalObject(nil, appId, autoRegister); + + if (launchMessage) + processNotificationOpened(); +} + +- (void) registerForPushNotifications { + [oneSignal registerForPushNotifications]; +} + +- (void) sendTag:(NSString*)key value:(NSString*)value { + [oneSignal sendTag:key value:value]; +} + +- (void) deleteTag:(NSString*)key { + [oneSignal deleteTag:key]; +} + +- (void) getTags { + [oneSignal getTags:^(NSDictionary* result) { + [PushWrapper onReceivedTags:self tags:dictionaryToJsonString(result)]; + }]; +} + +- (void) getIds { + [oneSignal IdsAvailable:^(NSString* playerId, NSString* pushToken) { + [PushWrapper onReceivedIds:self userid:playerId pushToken:pushToken]; + }]; +} + +@end diff --git a/plugins/OneSignal/proj.ios/PluginOneSignalPush.xcodeproj/project.pbxproj b/plugins/OneSignal/proj.ios/PluginOneSignalPush.xcodeproj/project.pbxproj new file mode 100644 index 00000000..1b455548 --- /dev/null +++ b/plugins/OneSignal/proj.ios/PluginOneSignalPush.xcodeproj/project.pbxproj @@ -0,0 +1,268 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 377A83A21AD759EF00DE19B1 /* OneSignal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 377A83A11AD759EF00DE19B1 /* OneSignal.framework */; }; + 37ACAEF81A153FC400D18B60 /* OneSignalPush.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 37ACAEF71A153FC400D18B60 /* OneSignalPush.h */; }; + 37ACAEFA1A153FC400D18B60 /* OneSignalPush.m in Sources */ = {isa = PBXBuildFile; fileRef = 37ACAEF91A153FC400D18B60 /* OneSignalPush.m */; }; + 37ACAF1A1A15814900D18B60 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 37ACAF191A15814900D18B60 /* UIKit.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 37ACAEF21A153FC400D18B60 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + 37ACAEF81A153FC400D18B60 /* OneSignalPush.h in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 377A83A11AD759EF00DE19B1 /* OneSignal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OneSignal.framework; path = sdk/OneSignal.framework; sourceTree = ""; }; + 37ACAEF41A153FC400D18B60 /* libPluginOneSignalPush.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPluginOneSignalPush.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 37ACAEF71A153FC400D18B60 /* OneSignalPush.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OneSignalPush.h; sourceTree = ""; }; + 37ACAEF91A153FC400D18B60 /* OneSignalPush.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OneSignalPush.m; sourceTree = ""; }; + 37ACAF191A15814900D18B60 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 37ACAEF11A153FC400D18B60 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 377A83A21AD759EF00DE19B1 /* OneSignal.framework in Frameworks */, + 37ACAF1A1A15814900D18B60 /* UIKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 37ACAEEB1A153FC400D18B60 = { + isa = PBXGroup; + children = ( + 377A83A11AD759EF00DE19B1 /* OneSignal.framework */, + 37ACAF191A15814900D18B60 /* UIKit.framework */, + 37ACAEF61A153FC400D18B60 /* OneSignalPush */, + 37ACAEF51A153FC400D18B60 /* Products */, + ); + sourceTree = ""; + }; + 37ACAEF51A153FC400D18B60 /* Products */ = { + isa = PBXGroup; + children = ( + 37ACAEF41A153FC400D18B60 /* libPluginOneSignalPush.a */, + ); + name = Products; + sourceTree = ""; + }; + 37ACAEF61A153FC400D18B60 /* OneSignalPush */ = { + isa = PBXGroup; + children = ( + 37ACAEF71A153FC400D18B60 /* OneSignalPush.h */, + 37ACAEF91A153FC400D18B60 /* OneSignalPush.m */, + ); + path = OneSignalPush; + sourceTree = SOURCE_ROOT; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 37ACAEF31A153FC400D18B60 /* PluginOneSignalPush */ = { + isa = PBXNativeTarget; + buildConfigurationList = 37ACAF081A153FC400D18B60 /* Build configuration list for PBXNativeTarget "PluginOneSignalPush" */; + buildPhases = ( + 37ACAEF01A153FC400D18B60 /* Sources */, + 37ACAEF11A153FC400D18B60 /* Frameworks */, + 37ACAEF21A153FC400D18B60 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = PluginOneSignalPush; + productName = GameThrivePush; + productReference = 37ACAEF41A153FC400D18B60 /* libPluginOneSignalPush.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 37ACAEEC1A153FC400D18B60 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0610; + ORGANIZATIONNAME = GameThrive; + TargetAttributes = { + 37ACAEF31A153FC400D18B60 = { + CreatedOnToolsVersion = 6.1; + }; + }; + }; + buildConfigurationList = 37ACAEEF1A153FC400D18B60 /* Build configuration list for PBXProject "PluginOneSignalPush" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 37ACAEEB1A153FC400D18B60; + productRefGroup = 37ACAEF51A153FC400D18B60 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 37ACAEF31A153FC400D18B60 /* PluginOneSignalPush */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 37ACAEF01A153FC400D18B60 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 37ACAEFA1A153FC400D18B60 /* OneSignalPush.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 37ACAF061A153FC400D18B60 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 37ACAF071A153FC400D18B60 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 37ACAF091A153FC400D18B60 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + "$(PROJECT_DIR)/sdk", + ); + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = PluginOneSignalPush; + SKIP_INSTALL = YES; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; + }; + name = Debug; + }; + 37ACAF0A1A153FC400D18B60 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + "$(PROJECT_DIR)/sdk", + ); + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = PluginOneSignalPush; + SKIP_INSTALL = YES; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 37ACAEEF1A153FC400D18B60 /* Build configuration list for PBXProject "PluginOneSignalPush" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 37ACAF061A153FC400D18B60 /* Debug */, + 37ACAF071A153FC400D18B60 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 37ACAF081A153FC400D18B60 /* Build configuration list for PBXNativeTarget "PluginOneSignalPush" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 37ACAF091A153FC400D18B60 /* Debug */, + 37ACAF0A1A153FC400D18B60 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 37ACAEEC1A153FC400D18B60 /* Project object */; +} diff --git a/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Headers b/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Headers new file mode 120000 index 00000000..a177d2a6 --- /dev/null +++ b/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Headers @@ -0,0 +1 @@ +Versions/Current/Headers \ No newline at end of file diff --git a/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/OneSignal b/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/OneSignal new file mode 120000 index 00000000..51c8d4e7 --- /dev/null +++ b/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/OneSignal @@ -0,0 +1 @@ +Versions/Current/OneSignal \ No newline at end of file diff --git a/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Resources b/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Resources new file mode 120000 index 00000000..953ee36f --- /dev/null +++ b/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Resources @@ -0,0 +1 @@ +Versions/Current/Resources \ No newline at end of file diff --git a/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Versions/A/Headers/GameThrive.h b/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Versions/A/Headers/GameThrive.h new file mode 100755 index 00000000..e1372d1a --- /dev/null +++ b/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Versions/A/Headers/GameThrive.h @@ -0,0 +1,101 @@ +/** + * Copyright 2014 GameThrive + * Portions Copyright 2014 StackMob + * + * This file includes portions from the StackMob iOS SDK and distributed under an Apache 2.0 license. + * StackMob was acquired by PayPal and ceased operation on May 22, 2014. + * + * 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. + */ + +// GameThrive is deprecated and is now OneSignal. Please update to use the OneSignal class as GameThrive will be removed in future versions. + +#import +#import + +typedef void (^GTResultSuccessBlock)(NSDictionary* result); +typedef void (^GTFailureBlock)(NSError* error); +typedef void (^GTIdsAvailableBlock)(NSString* playerId, NSString* pushToken); +typedef void (^GTHandleNotificationBlock)(NSString* message, NSDictionary* additionalData, BOOL isActive); + +/** + `GameThrive` provides a high level interface to interact with GameThrive's push service. + + `GameThrive` exposes a defaultClient for applications which use a globally available client to share configuration settings. + + Include `#import "GameThrive/GameThrive.h"` in your application files to access GameThrive's methods. + + ### Setting up the SDK ### + + Follow the documentation from http://documentation.gamethrive.com/v1.0/docs/installing-the-gamethrive-ios-sdk to setup with your game. + + */ + +__attribute__((deprecated)) +@interface GameThrive : NSObject + +@property(nonatomic, readonly, copy) NSString* app_id; + +extern NSString* const GT_VERSION; + +///-------------------- +/// @name Initialize +///-------------------- + +/** + Initialize GameThrive. Sends push token to GameThrive so you can later send notifications. + + */ + +- (id)initWithLaunchOptions:(NSDictionary*)launchOptions DEPRECATED_ATTRIBUTE; + +- (id)initWithLaunchOptions:(NSDictionary*)launchOptions autoRegister:(BOOL)autoRegister DEPRECATED_ATTRIBUTE; + +- (id)initWithLaunchOptions:(NSDictionary*)launchOptions handleNotification:(GTHandleNotificationBlock)callback DEPRECATED_ATTRIBUTE; + +- (id)initWithLaunchOptions:(NSDictionary*)launchOptions appId:(NSString*)appId handleNotification:(GTHandleNotificationBlock)callback DEPRECATED_ATTRIBUTE; + +- (id)initWithLaunchOptions:(NSDictionary*)launchOptions appId:(NSString*)appId handleNotification:(GTHandleNotificationBlock)callback autoRegister:(BOOL)autoRegister DEPRECATED_ATTRIBUTE; + +// Only use if you passed FALSE to autoRegister +- (void)registerForPushNotifications DEPRECATED_ATTRIBUTE; + + ++ (void)setDefaultClient:(GameThrive*)client DEPRECATED_ATTRIBUTE; ++ (GameThrive*)defaultClient DEPRECATED_ATTRIBUTE; + +- (void)sendTag:(NSString*)key value:(NSString*)value onSuccess:(GTResultSuccessBlock)successBlock onFailure:(GTFailureBlock)failureBlock DEPRECATED_ATTRIBUTE; +- (void)sendTag:(NSString*)key value:(NSString*)value DEPRECATED_ATTRIBUTE; + +- (void)sendTags:(NSDictionary*)keyValuePair onSuccess:(GTResultSuccessBlock)successBlock onFailure:(GTFailureBlock)failureBlock DEPRECATED_ATTRIBUTE; +- (void)sendTags:(NSDictionary*)keyValuePair DEPRECATED_ATTRIBUTE; +- (void)sendTagsWithJsonString:(NSString*)jsonString DEPRECATED_ATTRIBUTE; + +- (void)getTags:(GTResultSuccessBlock)successBlock onFailure:(GTFailureBlock)failureBlock DEPRECATED_ATTRIBUTE; +- (void)getTags:(GTResultSuccessBlock)successBlock DEPRECATED_ATTRIBUTE; + +- (void)deleteTag:(NSString*)key onSuccess:(GTResultSuccessBlock)successBlock onFailure:(GTFailureBlock)failureBlock DEPRECATED_ATTRIBUTE; +- (void)deleteTag:(NSString*)key DEPRECATED_ATTRIBUTE; + +- (void)deleteTags:(NSArray*)keys onSuccess:(GTResultSuccessBlock)successBlock onFailure:(GTFailureBlock)failureBlock DEPRECATED_ATTRIBUTE; +- (void)deleteTags:(NSArray*)keys DEPRECATED_ATTRIBUTE; +- (void)deleteTagsWithJsonString:(NSString*)jsonString DEPRECATED_ATTRIBUTE; + +- (void)sendPurchase:(NSNumber*)amount onSuccess:(GTResultSuccessBlock)successBlock onFailure:(GTFailureBlock)failureBlock DEPRECATED_ATTRIBUTE; +- (void)sendPurchase:(NSNumber*)amount DEPRECATED_ATTRIBUTE; + + +- (void)IdsAvailable:(GTIdsAvailableBlock)idsAvailableBlock; + +@end + diff --git a/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Versions/A/Headers/OneSignal.h b/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Versions/A/Headers/OneSignal.h new file mode 100755 index 00000000..c6a03818 --- /dev/null +++ b/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Versions/A/Headers/OneSignal.h @@ -0,0 +1,105 @@ +/** + * Copyright 2015 OneSignal + * Portions Copyright 2014 StackMob + * + * This file includes portions from the StackMob iOS SDK and distributed under an Apache 2.0 license. + * StackMob was acquired by PayPal and ceased operation on May 22, 2014. + * + * 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 +#import + +typedef void (^OneSignalResultSuccessBlock)(NSDictionary* result); +typedef void (^OneSignalFailureBlock)(NSError* error); +typedef void (^OneSignalIdsAvailableBlock)(NSString* userId, NSString* pushToken); +typedef void (^OneSignalHandleNotificationBlock)(NSString* message, NSDictionary* additionalData, BOOL isActive); + +/** + `OneSignal` provides a high level interface to interact with OneSignal's push service. + + `OneSignal` exposes a defaultClient for applications which use a globally available client to share configuration settings. + + Include `#import "OneSignal/OneSignal.h"` in your application files to access OneSignal's methods. + + ### Setting up the SDK ### + + Follow the documentation from http://documentation.gamethrive.com/v1.0/docs/installing-the-gamethrive-ios-sdk to setup with your game. + + */ +@interface OneSignal : NSObject + +@property(nonatomic, readonly, copy) NSString* app_id; + +extern NSString* const VERSION; + +typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) { + ONE_S_LL_NONE, ONE_S_LL_FATAL, ONE_S_LL_ERROR, ONE_S_LL_WARN, ONE_S_LL_INFO, ONE_S_LL_DEBUG, ONE_S_LL_VERBOSE +}; + +///-------------------- +/// @name Initialize +///-------------------- + +/** + Initialize OneSignal. Sends push token to OneSignal so you can later send notifications. + + */ + +- (id)initWithLaunchOptions:(NSDictionary*)launchOptions; + +- (id)initWithLaunchOptions:(NSDictionary*)launchOptions autoRegister:(BOOL)autoRegister; + +- (id)initWithLaunchOptions:(NSDictionary*)launchOptions handleNotification:(OneSignalHandleNotificationBlock)callback; + +- (id)initWithLaunchOptions:(NSDictionary*)launchOptions appId:(NSString*)appId handleNotification:(OneSignalHandleNotificationBlock)callback; + +- (id)initWithLaunchOptions:(NSDictionary*)launchOptions appId:(NSString*)appId handleNotification:(OneSignalHandleNotificationBlock)callback autoRegister:(BOOL)autoRegister; + +// Only use if you passed FALSE to autoRegister +- (void)registerForPushNotifications; + ++ (void)setLogLevel:(ONE_S_LOG_LEVEL)logLevel visualLevel:(ONE_S_LOG_LEVEL)visualLogLevel; + ++ (void)setDefaultClient:(OneSignal*)client; ++ (OneSignal*)defaultClient; + +- (void)sendTag:(NSString*)key value:(NSString*)value onSuccess:(OneSignalResultSuccessBlock)successBlock onFailure:(OneSignalFailureBlock)failureBlock; +- (void)sendTag:(NSString*)key value:(NSString*)value; + +- (void)sendTags:(NSDictionary*)keyValuePair onSuccess:(OneSignalResultSuccessBlock)successBlock onFailure:(OneSignalFailureBlock)failureBlock; +- (void)sendTags:(NSDictionary*)keyValuePair; +- (void)sendTagsWithJsonString:(NSString*)jsonString; + +- (void)getTags:(OneSignalResultSuccessBlock)successBlock onFailure:(OneSignalFailureBlock)failureBlock; +- (void)getTags:(OneSignalResultSuccessBlock)successBlock; + +- (void)deleteTag:(NSString*)key onSuccess:(OneSignalResultSuccessBlock)successBlock onFailure:(OneSignalFailureBlock)failureBlock; +- (void)deleteTag:(NSString*)key; + +- (void)deleteTags:(NSArray*)keys onSuccess:(OneSignalResultSuccessBlock)successBlock onFailure:(OneSignalFailureBlock)failureBlock; +- (void)deleteTags:(NSArray*)keys; +- (void)deleteTagsWithJsonString:(NSString*)jsonString; + +- (void)IdsAvailable:(OneSignalIdsAvailableBlock)idsAvailableBlock; + +- (void)enableInAppAlertNotification:(BOOL)enable; +- (void)setSubscription:(BOOL)enable; + +- (void)postNotification:(NSDictionary*)jsonData; +- (void)postNotification:(NSDictionary*)jsonData onSuccess:(OneSignalResultSuccessBlock)successBlock onFailure:(OneSignalFailureBlock)failureBlock; +- (void)postNotificationWithJsonString:(NSString*)jsonData onSuccess:(OneSignalResultSuccessBlock)successBlock onFailure:(OneSignalFailureBlock)failureBlock; + +@end + diff --git a/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Versions/A/OneSignal b/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Versions/A/OneSignal new file mode 100644 index 00000000..15f40121 Binary files /dev/null and b/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Versions/A/OneSignal differ diff --git a/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Versions/Current b/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Versions/Current new file mode 120000 index 00000000..8c7e5a66 --- /dev/null +++ b/plugins/OneSignal/proj.ios/sdk/OneSignal.framework/Versions/Current @@ -0,0 +1 @@ +A \ No newline at end of file diff --git a/protocols/include/ProtocolPush.h b/protocols/include/ProtocolPush.h new file mode 100644 index 00000000..d42ab627 --- /dev/null +++ b/protocols/include/ProtocolPush.h @@ -0,0 +1,74 @@ +/**************************************************************************** +Copyright (c) 2013 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + +#ifndef __CCX_PROTOCOL_PUSH_H__ +#define __CCX_PROTOCOL_PUSH_H__ + +#include "PluginProtocol.h" + +namespace cocos2d { namespace plugin { + + typedef void (*ProtocolPushDidReceiveRemoteNotification) (const char*, const char*, bool); + typedef void (*ProtocolPushReceivedTags) (const char*); + typedef void (*ProtocolPushReceivedIds) (const char*, const char*); + + class ProtocolPush : public PluginProtocol { + public: + ProtocolPush(); + virtual ~ProtocolPush(); + + void init(const char* appId, const char* googleProjectNumber, ProtocolPushDidReceiveRemoteNotification cb, bool autoRegister = true); + + // For iOS only and only if autoRegister was set to false. + void registerForPushNotifications(); + + void sendTag(const char* key, const char* value); + + void deleteTag(const char* key); + + void getTags(ProtocolPushReceivedTags cb); + + void getIds(ProtocolPushReceivedIds cb); + + inline ProtocolPushDidReceiveRemoteNotification& getCallbackDidReceiveRemoteNotification() { + return _notificationReceivedCallback; + } + + inline ProtocolPushReceivedTags& getCallbackReceivedTags() { + return _receivedTagsCallback; + } + + inline ProtocolPushReceivedIds& getCallbackReceivedIds() { + return _receivedIdsCallback; + } + + protected: + ProtocolPushDidReceiveRemoteNotification _notificationReceivedCallback; + ProtocolPushReceivedTags _receivedTagsCallback; + ProtocolPushReceivedIds _receivedIdsCallback; + }; + +}} // namespace cocos2d { namespace plugin { + +#endif /* __CCX_PROTOCOL_USER_H__ */ \ No newline at end of file diff --git a/protocols/platform/android/PluginFactory.cpp b/protocols/platform/android/PluginFactory.cpp index f6468a39..04bdd646 100644 --- a/protocols/platform/android/PluginFactory.cpp +++ b/protocols/platform/android/PluginFactory.cpp @@ -30,6 +30,7 @@ THE SOFTWARE. #include "ProtocolShare.h" #include "ProtocolUser.h" #include "ProtocolSocial.h" +#include "ProtocolPush.h" namespace cocos2d { namespace plugin { @@ -40,6 +41,7 @@ enum { kPluginShare, kPluginUser, kPluginSocial, + kPluginPush }; #define ANDROID_PLUGIN_PACKAGE_PREFIX "org/cocos2dx/plugin/" @@ -139,6 +141,8 @@ PluginProtocol* PluginFactory::createPlugin(const char* name) case kPluginSocial: pRet = new ProtocolSocial(); break; + case kPluginPush: + pRet = new ProtocolPush(); default: break; } diff --git a/protocols/platform/android/ProtocolPush.cpp b/protocols/platform/android/ProtocolPush.cpp new file mode 100644 index 00000000..ad358b47 --- /dev/null +++ b/protocols/platform/android/ProtocolPush.cpp @@ -0,0 +1,152 @@ +/**************************************************************************** +Copyright (c) 2013 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +#include "ProtocolPush.h" +#include "PluginJniHelper.h" +#include +#include "PluginUtils.h" +#include "PluginJavaData.h" + +namespace cocos2d { namespace plugin { + +extern "C" { + // TODO: Split this into 3 differnt ones for notificationReceived, tagsReceived, and idsReceived. + JNIEXPORT void JNICALL Java_org_cocos2dx_plugin_PushWrapper_nativeOnDidReceiveRemoteNotification(JNIEnv* env, jobject thiz, jstring className, jstring msg, jstring additionalData, bool isActive) { + std::string strMsg = PluginJniHelper::jstring2string(msg); + std::string strAdditionalData = PluginJniHelper::jstring2string(additionalData); + std::string strClassName = PluginJniHelper::jstring2string(className); + PluginProtocol* pPlugin = PluginUtils::getPluginPtr(strClassName); + PluginUtils::outputLog("ProtocolPush", "nativeOnDidReceiveRemoteNotification(), Get plugin ptr : %p", pPlugin); + if (pPlugin != NULL) { + PluginUtils::outputLog("ProtocolPush", "nativeOnDidReceiveRemoteNotification(), Get plugin name : %s", pPlugin->getPluginName()); + ProtocolPush* pUser = dynamic_cast(pPlugin); + + if (pUser != NULL) { + ProtocolPushDidReceiveRemoteNotification callback = pUser->getCallbackDidReceiveRemoteNotification(); + if (callback) + callback(strMsg.c_str(), strAdditionalData.c_str(), isActive); + } + } + } + + JNIEXPORT void JNICALL Java_org_cocos2dx_plugin_PushWrapper_nativeOnReceivedTags(JNIEnv* env, jobject thiz, jstring className, jstring tags) { + std::string strTags = PluginJniHelper::jstring2string(tags); + std::string strClassName = PluginJniHelper::jstring2string(className); + PluginProtocol* pPlugin = PluginUtils::getPluginPtr(strClassName); + PluginUtils::outputLog("ProtocolPush", "nativeOnActionResult(), Get plugin ptr : %p", pPlugin); + if (pPlugin != NULL) { + PluginUtils::outputLog("ProtocolPush", "nativeOnActionResult(), Get plugin name : %s", pPlugin->getPluginName()); + ProtocolPush* pUser = dynamic_cast(pPlugin); + + if (pUser != NULL) { + ProtocolPushReceivedTags callback = pUser->getCallbackReceivedTags(); + if (callback) + callback(strTags.c_str()); + } + } + } + + JNIEXPORT void JNICALL Java_org_cocos2dx_plugin_PushWrapper_nativeOnReceivedIds(JNIEnv* env, jobject thiz, jstring className, jstring userId, jstring pushToken) { + std::string strUserId = PluginJniHelper::jstring2string(userId); + std::string strPushToken = PluginJniHelper::jstring2string(pushToken); + std::string strClassName = PluginJniHelper::jstring2string(className); + PluginProtocol* pPlugin = PluginUtils::getPluginPtr(strClassName); + PluginUtils::outputLog("ProtocolPush", "nativeOnReceivedIds(), Get plugin ptr : %p", pPlugin); + if (pPlugin != NULL) { + PluginUtils::outputLog("ProtocolPush", "nativeOnReceivedIds(), Get plugin name : %s", pPlugin->getPluginName()); + ProtocolPush* pUser = dynamic_cast(pPlugin); + + if (pUser != NULL) { + ProtocolPushReceivedIds callback = pUser->getCallbackReceivedIds(); + if (callback) + callback(strUserId.c_str(), strPushToken.c_str()); + } + } + } + +} + +ProtocolPush::ProtocolPush() {} +ProtocolPush::~ProtocolPush() {} + +void ProtocolPush::init(const char* appId, const char* googleProjectNumber, ProtocolPushDidReceiveRemoteNotification cb, bool autoRegister) { + _notificationReceivedCallback = cb; + + PluginJavaData* pData = PluginUtils::getPluginJavaData(this); + PluginJniMethodInfo t; + if (PluginJniHelper::getMethodInfo(t, + pData->jclassName.c_str(), + "init", + "(Ljava/lang/String;Ljava/lang/String;)V")) { + + // invoke java method + t.env->CallVoidMethod(pData->jobj, t.methodID, t.env->NewStringUTF(googleProjectNumber), t.env->NewStringUTF(appId)); + t.env->DeleteLocalRef(t.classID); + } +} + +void ProtocolPush::registerForPushNotifications() { + // Does nothing for Android as we always auto register for push. +} + +void ProtocolPush::sendTag(const char* key, const char* value) { + PluginJavaData* pData = PluginUtils::getPluginJavaData(this); + PluginJniMethodInfo t; + if (PluginJniHelper::getMethodInfo(t, + pData->jclassName.c_str(), + "sendTag", + "(Ljava/lang/String;Ljava/lang/String;)V")) { + + // invoke java method + t.env->CallVoidMethod(pData->jobj, t.methodID, t.env->NewStringUTF(key), t.env->NewStringUTF(value)); + t.env->DeleteLocalRef(t.classID); + } +} + +void ProtocolPush::deleteTag(const char* key) { + PluginJavaData* pData = PluginUtils::getPluginJavaData(this); + PluginJniMethodInfo t; + if (PluginJniHelper::getMethodInfo(t, + pData->jclassName.c_str(), + "sendTag", + "(Ljava/lang/String;)V")) { + + // invoke java method + t.env->CallVoidMethod(pData->jobj, t.methodID, t.env->NewStringUTF(key)); + t.env->DeleteLocalRef(t.classID); + } +} + +void ProtocolPush::getTags(ProtocolPushReceivedTags cb) { + _receivedTagsCallback = cb; + + PluginUtils::callJavaFunctionWithName(this, "getTags"); +} + +void ProtocolPush::getIds(ProtocolPushReceivedIds cb) { + _receivedIdsCallback = cb; + + PluginUtils::callJavaFunctionWithName(this, "getIds"); +} + +}} // namespace cocos2d { namespace plugin { diff --git a/protocols/platform/ios/InterfacePush.h b/protocols/platform/ios/InterfacePush.h new file mode 100644 index 00000000..f5864bc4 --- /dev/null +++ b/protocols/platform/ios/InterfacePush.h @@ -0,0 +1,30 @@ +/**************************************************************************** + Copyright (c) 2012+2013 cocos2d+x.org + http://www.cocos2d+x.org + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +@protocol 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 \ No newline at end of file diff --git a/protocols/platform/ios/PluginFactory.mm b/protocols/platform/ios/PluginFactory.mm index 788156ff..05586d0d 100644 --- a/protocols/platform/ios/PluginFactory.mm +++ b/protocols/platform/ios/PluginFactory.mm @@ -28,6 +28,7 @@ of this software and associated documentation files (the "Software"), to deal #include "ProtocolShare.h" #include "ProtocolSocial.h" #include "ProtocolUser.h" +#include "ProtocolPush.h" #include "PluginUtilsIOS.h" #import @@ -37,6 +38,7 @@ of this software and associated documentation files (the "Software"), to deal #import "InterfaceShare.h" #import "InterfaceSocial.h" #import "InterfaceUser.h" +#import "InterfacePush.h" namespace cocos2d { namespace plugin { @@ -107,6 +109,9 @@ of this software and associated documentation files (the "Software"), to deal } else if ([obj conformsToProtocol:@protocol(InterfaceUser)]) { pRet = new ProtocolUser(); + } else + if ([obj conformsToProtocol:@protocol(InterfacePush)]) { + pRet = new ProtocolPush(); } else { PluginUtilsIOS::outputLog("Plugin %s not implements a right protocol", name); } diff --git a/protocols/platform/ios/ProtocolPush.mm b/protocols/platform/ios/ProtocolPush.mm new file mode 100644 index 00000000..2fce5208 --- /dev/null +++ b/protocols/platform/ios/ProtocolPush.mm @@ -0,0 +1,89 @@ +/**************************************************************************** + Copyright (c) 2012-2013 cocos2d-x.org + http://www.cocos2d-x.org + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +#include "ProtocolPush.h" +#include "PluginUtilsIOS.h" +#import "InterfacePush.h" + +namespace cocos2d { namespace plugin { + + ProtocolPush::ProtocolPush() {} + ProtocolPush::~ProtocolPush() {} + + void ProtocolPush::init(const char* appId, const char* googleProjectNumber, ProtocolPushDidReceiveRemoteNotification cb, bool autoRegister) { + _notificationReceivedCallback = cb; + + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfacePush)]) { + NSObject* curObj = ocObj; + [curObj initWithAppId:[NSString stringWithUTF8String:appId] autoRegister:autoRegister]; + } + } + + void ProtocolPush::registerForPushNotifications() { + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfacePush)]) { + NSObject* curObj = ocObj; + [curObj registerForPushNotifications]; + } + } + + void ProtocolPush::sendTag(const char *key, const char *value) { + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfacePush)]) { + NSObject* curObj = ocObj; + [curObj sendTag:[NSString stringWithUTF8String:key] value:[NSString stringWithUTF8String:value]]; + } + } + + void ProtocolPush::deleteTag(const char *key) { + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfacePush)]) { + NSObject* curObj = ocObj; + [curObj deleteTag:[NSString stringWithUTF8String:key]]; + } + } + + void ProtocolPush::getTags(ProtocolPushReceivedTags cb) { + _receivedTagsCallback = cb; + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfacePush)]) { + NSObject* curObj = ocObj; + [curObj getTags]; + } + } + + void ProtocolPush::getIds(ProtocolPushReceivedIds cb) { + _receivedIdsCallback = cb; + PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); + + id ocObj = pData->obj; + if ([ocObj conformsToProtocol:@protocol(InterfacePush)]) { + NSObject* curObj = ocObj; + [curObj getIds]; + } + } + +}} // namespace cocos2d { namespace plugin { diff --git a/protocols/platform/ios/PushWrapper.h b/protocols/platform/ios/PushWrapper.h new file mode 100644 index 00000000..fee19321 --- /dev/null +++ b/protocols/platform/ios/PushWrapper.h @@ -0,0 +1,29 @@ +/**************************************************************************** + Copyright (c) 2012+2013 cocos2d+x.org + http://www.cocos2d+x.org + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#import + +@interface PushWrapper : NSObject { +} + ++ (void) onDidReceiveRemoteNotification:(id)obj message:(NSString*)message additionalData:(NSString*)additionalData isActive:(BOOL)isActive; ++ (void) onReceivedTags:(id)obj tags:(NSString*)tags; ++ (void) onReceivedIds:(id)obj userid:(NSString*)userId pushToken:(NSString*)pushToken; +@end \ No newline at end of file diff --git a/protocols/platform/ios/PushWrapper.mm b/protocols/platform/ios/PushWrapper.mm new file mode 100644 index 00000000..4457fb9d --- /dev/null +++ b/protocols/platform/ios/PushWrapper.mm @@ -0,0 +1,71 @@ +/**************************************************************************** + Copyright (c) 2012+2013 cocos2d+x.org + http://www.cocos2d+x.org + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#import "PushWrapper.h" +#include "PluginUtilsIOS.h" +#include "ProtocolPush.h" + +using namespace cocos2d::plugin; + +@implementation PushWrapper + ++ (void) onDidReceiveRemoteNotification:(id)obj message:(NSString*)message additionalData:(NSString*)additionalData isActive:(BOOL)isActive { + PluginProtocol* pPlugin = PluginUtilsIOS::getPluginPtr(obj); + ProtocolPush* pPush = dynamic_cast(pPlugin); + if (pPush) { + ProtocolPushDidReceiveRemoteNotification callback = pPush->getCallbackDidReceiveRemoteNotification(); + const char* strAdditionalData = nil; + if (additionalData) + strAdditionalData = [additionalData UTF8String]; + callback([message UTF8String], strAdditionalData, isActive); + } + else + PluginUtilsIOS::outputLog("Can't find the C++ object of the Push plugin"); +} + ++ (void) onReceivedTags:(id)obj tags:(NSString*)tags { + PluginProtocol* pPlugin = PluginUtilsIOS::getPluginPtr(obj); + ProtocolPush* pPush = dynamic_cast(pPlugin); + if (pPush) { + ProtocolPushReceivedTags callback = pPush->getCallbackReceivedTags(); + const char* strTags = nil; + if (tags) + strTags = [tags UTF8String]; + callback(strTags); + } + else + PluginUtilsIOS::outputLog("Can't find the C++ object of the Push plugin"); +} + ++ (void) onReceivedIds:(id)obj userid:(NSString*)userId pushToken:(NSString*)pushToken { + PluginProtocol* pPlugin = PluginUtilsIOS::getPluginPtr(obj); + ProtocolPush* pPush = dynamic_cast(pPlugin); + if (pPush) { + ProtocolPushReceivedIds callback = pPush->getCallbackReceivedIds(); + const char* strPushToken = nil; + if (pushToken) + strPushToken = [pushToken UTF8String]; + callback([userId UTF8String], strPushToken); + } + else + PluginUtilsIOS::outputLog("Can't find the C++ object of the Push plugin"); +} + +@end \ No newline at end of file diff --git a/protocols/proj.android/jni/Android.mk b/protocols/proj.android/jni/Android.mk index 7c65ab78..4803a29c 100755 --- a/protocols/proj.android/jni/Android.mk +++ b/protocols/proj.android/jni/Android.mk @@ -20,6 +20,7 @@ $(addprefix ../../platform/android/, \ ProtocolSocial.cpp \ AgentManager.cpp \ FacebookAgent.cpp \ + ProtocolPush.cpp \ ) \ ../../PluginManager.cpp \ ../../PluginParam.cpp diff --git a/protocols/proj.android/src/org/cocos2dx/plugin/InterfacePush.java b/protocols/proj.android/src/org/cocos2dx/plugin/InterfacePush.java new file mode 100644 index 00000000..6c763c02 --- /dev/null +++ b/protocols/proj.android/src/org/cocos2dx/plugin/InterfacePush.java @@ -0,0 +1,34 @@ +/**************************************************************************** +Copyright (c) 2012-2013 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +package org.cocos2dx.plugin; + +public interface InterfacePush { + public final int PluginType = 7; + + public void init(String googleProjectNumber, String appId); + public void sendTag(String key, String value); + public void deleteTag(String key); + public void getTags(); + public void getIds(); +} diff --git a/protocols/proj.android/src/org/cocos2dx/plugin/PushWrapper.java b/protocols/proj.android/src/org/cocos2dx/plugin/PushWrapper.java new file mode 100644 index 00000000..6d89add5 --- /dev/null +++ b/protocols/proj.android/src/org/cocos2dx/plugin/PushWrapper.java @@ -0,0 +1,78 @@ +/**************************************************************************** +Copyright (c) 2012-2013 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +package org.cocos2dx.plugin; + +public class PushWrapper { + + public static void onDidReceiveRemoteNotification(InterfacePush obj, String msg, String additionalData, boolean isActive) { + final String curMsg = msg; + final String curAdditionalData = additionalData; + final boolean curIsActive = isActive; + final InterfacePush curAdapter = obj; + + PluginWrapper.runOnGLThread(new Runnable() { + @Override + public void run() { + String name = curAdapter.getClass().getName(); + name = name.replace('.', '/'); + nativeOnDidReceiveRemoteNotification(name, curMsg, curAdditionalData, curIsActive); + } + }); + } + + private static native void nativeOnDidReceiveRemoteNotification(String className, String msg, String additionalData, boolean isActive); + + public static void onReceivedTags(InterfacePush obj, String tags) { + final String curTags = tags; + final InterfacePush curAdapter = obj; + + PluginWrapper.runOnGLThread(new Runnable() { + @Override + public void run() { + String name = curAdapter.getClass().getName(); + name = name.replace('.', '/'); + nativeOnReceivedTags(name, curTags); + } + }); + } + + private static native void nativeOnReceivedTags(String className, String tags); + + public static void onReceivedIds(InterfacePush obj, String userId, String registrationId) { + final String curUserId = userId; + final String curRegistrationId = registrationId; + final InterfacePush curAdapter = obj; + + PluginWrapper.runOnGLThread(new Runnable() { + @Override + public void run() { + String name = curAdapter.getClass().getName(); + name = name.replace('.', '/'); + nativeOnReceivedIds(name, curUserId, curRegistrationId); + } + }); + } + + private static native void nativeOnReceivedIds(String className, String userId, String pushToken); +} \ No newline at end of file diff --git a/protocols/proj.ios/PluginProtocol.xcodeproj/project.pbxproj b/protocols/proj.ios/PluginProtocol.xcodeproj/project.pbxproj index 337920fa..f9ff2a7f 100644 --- a/protocols/proj.ios/PluginProtocol.xcodeproj/project.pbxproj +++ b/protocols/proj.ios/PluginProtocol.xcodeproj/project.pbxproj @@ -10,6 +10,8 @@ 051FF7BC192CE3CC00C43A06 /* IAPWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 051FF7BB192CE3CC00C43A06 /* IAPWrapper.mm */; }; 059B0A7E19864CE1004B06D4 /* FacebookAgent.mm in Sources */ = {isa = PBXBuildFile; fileRef = 059B0A7D19864CE1004B06D4 /* FacebookAgent.mm */; }; 05AB25181988F62000D00E8E /* ParseUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 05AB25171988F62000D00E8E /* ParseUtils.m */; }; + 37ACAF121A15476200D18B60 /* ProtocolPush.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37ACAF111A15476200D18B60 /* ProtocolPush.mm */; }; + 37ACAF181A1575BD00D18B60 /* PushWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37ACAF171A1575BD00D18B60 /* PushWrapper.mm */; }; BA1BF842195A6FC100B47F4E /* AgentManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = BA1BF841195A6FC100B47F4E /* AgentManager.mm */; }; FA09A325168ADBC2008C1C7B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA09A324168ADBC2008C1C7B /* Foundation.framework */; }; FA09A33E168ADC1F008C1C7B /* PluginManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA09A33C168ADC1F008C1C7B /* PluginManager.cpp */; }; @@ -49,6 +51,11 @@ 059B0A7D19864CE1004B06D4 /* FacebookAgent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FacebookAgent.mm; sourceTree = ""; }; 05AB25161988F62000D00E8E /* ParseUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParseUtils.h; sourceTree = ""; }; 05AB25171988F62000D00E8E /* ParseUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ParseUtils.m; sourceTree = ""; }; + 37ACAF101A15442D00D18B60 /* InterfacePush.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InterfacePush.h; sourceTree = ""; }; + 37ACAF111A15476200D18B60 /* ProtocolPush.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProtocolPush.mm; sourceTree = ""; }; + 37ACAF131A1547BA00D18B60 /* ProtocolPush.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProtocolPush.h; sourceTree = ""; }; + 37ACAF161A1573A500D18B60 /* PushWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PushWrapper.h; sourceTree = ""; }; + 37ACAF171A1575BD00D18B60 /* PushWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PushWrapper.mm; sourceTree = ""; }; BA1BF7FE195962C400B47F4E /* AgentManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AgentManager.h; sourceTree = ""; }; BA1BF841195A6FC100B47F4E /* AgentManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AgentManager.mm; sourceTree = ""; }; FA09A321168ADBC2008C1C7B /* libPluginProtocol.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPluginProtocol.a; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -138,6 +145,7 @@ FA09A336168ADC05008C1C7B /* include */ = { isa = PBXGroup; children = ( + 37ACAF131A1547BA00D18B60 /* ProtocolPush.h */, 059B0A79198649F0004B06D4 /* FacebookAgent.h */, BA1BF7FE195962C400B47F4E /* AgentManager.h */, FADBF896179E504B00F59B1D /* ProtocolSocial.h */, @@ -189,6 +197,10 @@ FA8CC1E5173754CF00464206 /* PluginUtilsIOS.mm */, 05AB25161988F62000D00E8E /* ParseUtils.h */, 05AB25171988F62000D00E8E /* ParseUtils.m */, + 37ACAF101A15442D00D18B60 /* InterfacePush.h */, + 37ACAF111A15476200D18B60 /* ProtocolPush.mm */, + 37ACAF161A1573A500D18B60 /* PushWrapper.h */, + 37ACAF171A1575BD00D18B60 /* PushWrapper.mm */, ); name = ios; path = ../platform/ios; @@ -253,6 +265,7 @@ FA8CC20A173894F000464206 /* ProtocolIAP.mm in Sources */, FAB6DF961755D7E500C90D89 /* PluginParam.cpp in Sources */, FAB6DF981755D82F00C90D89 /* PluginFactory.mm in Sources */, + 37ACAF181A1575BD00D18B60 /* PushWrapper.mm in Sources */, 059B0A7E19864CE1004B06D4 /* FacebookAgent.mm in Sources */, FAB6DF9A1755D93600C90D89 /* PluginProtocol.mm in Sources */, FADC44CA176EABCF00B2D5ED /* AdsWrapper.mm in Sources */, @@ -264,6 +277,7 @@ FADBF89B179E509500F59B1D /* ProtocolSocial.mm in Sources */, 05AB25181988F62000D00E8E /* ParseUtils.m in Sources */, FADBF89C179E509500F59B1D /* SocialWrapper.mm in Sources */, + 37ACAF121A15476200D18B60 /* ProtocolPush.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/samples/HelloPlugins/Classes/HelloWorldScene.cpp b/samples/HelloPlugins/Classes/HelloWorldScene.cpp index 3620296f..df282cdd 100644 --- a/samples/HelloPlugins/Classes/HelloWorldScene.cpp +++ b/samples/HelloPlugins/Classes/HelloWorldScene.cpp @@ -8,6 +8,7 @@ #include "TestSocialScene.h" #include "TestFacebookUserScene.h" #include "TestFacebookShare.h" +#include "TestPushScene.h" USING_NS_CC; @@ -17,11 +18,12 @@ std::string g_testCases[] = { "Test Share", "Test Facebook User", "Test Facebook Share", + "Test Push", #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) "Test IAP", "Test IAP Online", "Test User", - "Test Social", + "Test Social" #endif }; @@ -105,18 +107,19 @@ void HelloWorld::menuCallback(Ref* pSender) newScene = TestFacebookShare::scene(); break; case 5: - newScene = TestIAP::scene(); + newScene = TestPush::scene(); break; case 6: - newScene = TestIAPOnline::scene(); + newScene = TestIAP::scene(); break; case 7: - newScene = TestUser::scene(); + newScene = TestIAPOnline::scene(); break; case 8: - newScene = TestSocial::scene(); + newScene = TestUser::scene(); break; case 9: + newScene = TestSocial::scene(); break; default: break; diff --git a/samples/HelloPlugins/Classes/TestPush/MyPushManager.cpp b/samples/HelloPlugins/Classes/TestPush/MyPushManager.cpp new file mode 100644 index 00000000..eaf8c344 --- /dev/null +++ b/samples/HelloPlugins/Classes/TestPush/MyPushManager.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +Copyright (c) 2012-2013 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +#include "MyPushManager.h" +#include "PluginManager.h" +#include "cocos2d.h" +#include "Configs.h" +#include "ProtocolPush.h" + +#define COCOS2D_DEBUG 1 + +using namespace cocos2d::plugin; +using namespace cocos2d; + +MyPushManager* MyPushManager::s_pManager = NULL; + +PushReceived MyPushManager::_pushReceived; + +MyPushManager::MyPushManager() { } + +MyPushManager::~MyPushManager() { + unloadPlugin(); +} + +MyPushManager* MyPushManager::getInstance() { + if (s_pManager == NULL) { + s_pManager = new MyPushManager(); + } + return s_pManager; +} + +void MyPushManager::purgeManager() { + if (s_pManager) { + delete s_pManager; + s_pManager = NULL; + } + PluginManager::end(); +} + +void MyPushManager::loadPlugin() { + _push = (cocos2d::plugin::ProtocolPush*)PluginManager::getInstance()->loadPlugin("OneSignalPush"); + CCLog("MyPushManager::loadPlugin:%d", _push == NULL); +} + +void MyPushManager::HandleReceivedNotification(const char* message, const char* additionalData, bool isActive) { + CCLog("MyPushManager::HandleReceivedNotification"); + CCLog("message: %s", message); + CCLog("additionalData: %s", additionalData); + _pushReceived(message); +} + +void MyPushManager::unloadPlugin() { + if (_push) { + PluginManager::getInstance()->unloadPlugin("OneSignalPush"); + _push = NULL; + } +} + +void MyPushManager::init(PushReceived cb) { + if (_push) { + _pushReceived = cb; + _push->init("b49e69ca-d0b8-11e3-97bf-c3d1433e8bc1", "703322744261", (ProtocolPushDidReceiveRemoteNotification) HandleReceivedNotification); + } +} + +void MyPushManager::sendTag() { + if (_push) { + _push->sendTag("cocos2d-x", "demo"); + } +} diff --git a/samples/HelloPlugins/Classes/TestPush/MyPushManager.h b/samples/HelloPlugins/Classes/TestPush/MyPushManager.h new file mode 100644 index 00000000..f986a657 --- /dev/null +++ b/samples/HelloPlugins/Classes/TestPush/MyPushManager.h @@ -0,0 +1,53 @@ +/**************************************************************************** +Copyright (c) 2012-2013 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +#ifndef __MY_PUSH_MANAGER_H__ +#define __MY_PUSH_MANAGER_H__ + +#include "ProtocolPush.h" +#include "Configs.h" + +typedef void (*PushReceived) (const char*); + +class MyPushManager { +public: + static MyPushManager* getInstance(); + static void purgeManager(); + + void unloadPlugin(); + void loadPlugin(); + void init(PushReceived cb); + void sendTag(); + + static void HandleReceivedNotification(const char* message, const char* additionalData, bool isActive); + +private: + MyPushManager(); + virtual ~MyPushManager(); + + cocos2d::plugin::ProtocolPush* _push; + static PushReceived _pushReceived; + static MyPushManager* s_pManager; +}; + +#endif // __MY_PUSH_MANAGER_H__ diff --git a/samples/HelloPlugins/Classes/TestPush/TestPushScene.cpp b/samples/HelloPlugins/Classes/TestPush/TestPushScene.cpp new file mode 100644 index 00000000..b2cce903 --- /dev/null +++ b/samples/HelloPlugins/Classes/TestPush/TestPushScene.cpp @@ -0,0 +1,133 @@ +/**************************************************************************** +Copyright (c) 2013 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +#include "TestPushScene.h" +#include "MyPushManager.h" +#include "HelloWorldScene.h" + +#define COCOS2D_DEBUG 1 + +USING_NS_CC; + +Label* TestPush::newMessageLabel; + + +Scene* TestPush::scene() +{ + // 'scene' is an autorelease object + Scene *scene = Scene::create(); + + // 'layer' is an autorelease object + TestPush *layer = TestPush::create(); + + // add layer as a child to scene + scene->addChild(layer); + + // return the scene + return scene; +} + +// on "init" you need to initialize your instance +bool TestPush::init() +{ + ////////////////////////////// + // 1. super init first + if ( !Layer::init() ) + return false; + + CCLog("TestPush::init("); + + MyPushManager::getInstance()->loadPlugin(); + Size visibleSize = Director::getInstance()->getVisibleSize(); + Point origin = Director::getInstance()->getVisibleOrigin(); + Point posMid = Point(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2); + Point posBR = Point(origin.x + visibleSize.width, origin.y); + + ///////////////////////////// + // 2. add a menu item with "X" image, which is clicked to quit the program + // you may modify it. + + // add a "close" icon to exit the progress. it's an autorelease object + MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestPush::menuBackCallback, this)); + Size backSize = pBackItem->getContentSize(); + pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2)); + + // create menu, it's an autorelease object + Menu* pMenu = Menu::create(pBackItem, NULL); + pMenu->setPosition(Point::ZERO); + + Label* label1 = Label::create("Init", "Arial", 32); + MenuItemLabel* pItemLogin = MenuItemLabel::create(label1, CC_CALLBACK_1(TestPush::testInit, this)); + pItemLogin->setAnchorPoint(Point(0.5f, 0)); + pMenu->addChild(pItemLogin, 0); + pItemLogin->setPosition(posMid + Point(-100, -120)); + + Label* label2 = Label::create("sendTag", "Arial", 32); + MenuItemLabel* pItemLogout = MenuItemLabel::create(label2, CC_CALLBACK_1(TestPush::testSendTag, this)); + pItemLogout->setAnchorPoint(Point(0.5f, 0)); + pMenu->addChild(pItemLogout, 0); + pItemLogout->setPosition(posMid + Point(100, -120)); + + // create optional menu + // cases item + _caseItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(TestPush::caseChanged, this), + MenuItemFont::create( "OneSignal" ), + NULL ); + int caseLen = 2 / sizeof(std::string); + _caseItem->getSubItems().pushBack( MenuItemFont::create( "OneSignal" ) ); + _caseItem->setPosition(posMid + Point(0, 120)); + pMenu->addChild(_caseItem); + + this->addChild(pMenu, 1); + + + TestPush::newMessageLabel = Label::create("", "Arial", 25); + TestPush::newMessageLabel->setPosition(posMid + Point(0, -200)); + this->addChild(TestPush::newMessageLabel, 0); + + return true; +} + +void TestPush::onPushReceived(const char* message) { + TestPush::newMessageLabel->setString(message); +} + +void TestPush::caseChanged(Ref* pSender) { +} + +void TestPush::testInit(Ref* pSender) { + // NOTE: Init is called from a button for testing here but you should always call init when app first starts so notifications are not missed. + MyPushManager::getInstance()->init((PushReceived)onPushReceived); +} + +void TestPush::testSendTag(Ref* pSender) { + MyPushManager::getInstance()->sendTag(); +} + +void TestPush::menuBackCallback(Ref* pSender) +{ + MyPushManager::purgeManager(); + + Scene* newScene = HelloWorld::scene(); + Director::getInstance()->replaceScene(newScene); +} diff --git a/samples/HelloPlugins/Classes/TestPush/TestPushScene.h b/samples/HelloPlugins/Classes/TestPush/TestPushScene.h new file mode 100644 index 00000000..9428b808 --- /dev/null +++ b/samples/HelloPlugins/Classes/TestPush/TestPushScene.h @@ -0,0 +1,56 @@ +/**************************************************************************** +Copyright (c) 2013 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +#ifndef __TEST_PUSH_SCENE_H__ +#define __TEST_PUSH_SCENE_H__ + +#include "cocos2d.h" +#include "MyPushManager.h" + +class TestPush : public cocos2d::Layer { +public: + // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone + virtual bool init(); + + // there's no 'id' in cpp, so we recommend returning the class instance pointer + static cocos2d::Scene* scene(); + + // a selector callback + void menuBackCallback(Ref* pSender); + void testInit(Ref* pSender); + void testSendTag(Ref* pSender); + + void caseChanged(Ref* pSender); + + static void onPushReceived(const char* message); + + // implement the "static node()" method manually + CREATE_FUNC(TestPush); + +private: + cocos2d::MenuItemToggle* _caseItem; + int _selectedCase; + static cocos2d::Label* newMessageLabel; +}; + +#endif // __TEST_PUSH_SCENE_H__ diff --git a/samples/HelloPlugins/proj.android/.classpath b/samples/HelloPlugins/proj.android/.classpath index b1b91519..822b22c7 100644 --- a/samples/HelloPlugins/proj.android/.classpath +++ b/samples/HelloPlugins/proj.android/.classpath @@ -38,5 +38,7 @@ + + diff --git a/samples/HelloPlugins/proj.android/AndroidManifest.xml b/samples/HelloPlugins/proj.android/AndroidManifest.xml index 55d02231..3f630be5 100644 --- a/samples/HelloPlugins/proj.android/AndroidManifest.xml +++ b/samples/HelloPlugins/proj.android/AndroidManifest.xml @@ -83,6 +83,21 @@ + + + + + + + + + + + + @@ -103,4 +118,9 @@ - + + + + + + \ No newline at end of file diff --git a/samples/HelloPlugins/proj.android/jni/Android.mk b/samples/HelloPlugins/proj.android/jni/Android.mk index 1490827f..d8dff8fb 100644 --- a/samples/HelloPlugins/proj.android/jni/Android.mk +++ b/samples/HelloPlugins/proj.android/jni/Android.mk @@ -27,7 +27,9 @@ LOCAL_SRC_FILES := hellocpp/main.cpp \ ../../Classes/TestSocial/TestSocialScene.cpp \ ../../Classes/TestSocial/MySocialManager.cpp \ ../../Classes/TestFacebookUser/TestFacebookUserScene.cpp \ - ../../Classes/TestFacebookShare/TestFacebookShare.cpp + ../../Classes/TestFacebookShare/TestFacebookShare.cpp \ + ../../Classes/TestPush/TestPushScene.cpp \ + ../../Classes/TestPush/MyPushManager.cpp LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \ $(LOCAL_PATH)/../../Classes/TestAds \ @@ -38,7 +40,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \ $(LOCAL_PATH)/../../Classes/TestIAPOnline \ $(LOCAL_PATH)/../../Classes/TestSocial \ $(LOCAL_PATH)/../../Classes/TestFacebookUser \ - $(LOCAL_PATH)/../../Classes/TestFacebookShare + $(LOCAL_PATH)/../../Classes/TestFacebookShare \ + $(LOCAL_PATH)/../../Classes/TestPush diff --git a/samples/HelloPlugins/proj.android/libs/google-play-services-no-ads.jar b/samples/HelloPlugins/proj.android/libs/google-play-services-no-ads.jar new file mode 100644 index 00000000..9413b7ab Binary files /dev/null and b/samples/HelloPlugins/proj.android/libs/google-play-services-no-ads.jar differ diff --git a/samples/HelloPlugins/proj.android/res/values/version.xml b/samples/HelloPlugins/proj.android/res/values/version.xml new file mode 100644 index 00000000..8a5844cf --- /dev/null +++ b/samples/HelloPlugins/proj.android/res/values/version.xml @@ -0,0 +1,4 @@ + + + 6171000 + \ No newline at end of file diff --git a/samples/HelloPlugins/proj.ios/HelloPlugins.xcodeproj/project.pbxproj b/samples/HelloPlugins/proj.ios/HelloPlugins.xcodeproj/project.pbxproj index f91a3167..9756c726 100644 --- a/samples/HelloPlugins/proj.ios/HelloPlugins.xcodeproj/project.pbxproj +++ b/samples/HelloPlugins/proj.ios/HelloPlugins.xcodeproj/project.pbxproj @@ -20,10 +20,14 @@ 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; + 377A83A41AD7611300DE19B1 /* OneSignal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 377A83A31AD7611300DE19B1 /* OneSignal.framework */; }; + 37ACAEE91A15393A00D18B60 /* MyPushManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37ACAEE51A15393A00D18B60 /* MyPushManager.cpp */; }; + 37ACAEEA1A15393A00D18B60 /* TestPushScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37ACAEE71A15393A00D18B60 /* TestPushScene.cpp */; }; + 37ACAF1D1A158D3800D18B60 /* libPluginGameThrivePush.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 37ACAF1C1A158D3800D18B60 /* libPluginGameThrivePush.a */; }; + 37ACAF241A158ECE00D18B60 /* FBAudienceNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 37ACAF231A158ECE00D18B60 /* FBAudienceNetwork.framework */; }; 591A8D2419DF4DB700F71BFD /* libPluginFacebook.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 591A8D2219DF4DB700F71BFD /* libPluginFacebook.a */; }; 591A8D2519DF4DB700F71BFD /* libPluginFacebookAds.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 591A8D2319DF4DB700F71BFD /* libPluginFacebookAds.a */; }; 592A55791964AD7D008E4BC7 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 592A55781964AD7D008E4BC7 /* GameController.framework */; }; - 593E0BDD19BE206C00836D29 /* FBAudienceNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 593E0BDC19BE206C00836D29 /* FBAudienceNetwork.framework */; }; 59EB3BE719649CFC0020118E /* libcocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA848852182B3AE400858BDD /* libcocos2d iOS.a */; }; 59EB3BEA1964A7DD0020118E /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 59EB3BE91964A7DD0020118E /* Security.framework */; }; 59EB3BEC1964A86D0020118E /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 59EB3BEB1964A86D0020118E /* CoreTelephony.framework */; }; @@ -119,10 +123,16 @@ 1D6058910D05DD3D006BFB54 /* HelloPlugins.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloPlugins.app; sourceTree = BUILT_PRODUCTS_DIR; }; 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 377A83A31AD7611300DE19B1 /* OneSignal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OneSignal.framework; path = ../../../plugins/OneSignal/proj.ios/sdk/OneSignal.framework; sourceTree = ""; }; + 37ACAEE51A15393A00D18B60 /* MyPushManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MyPushManager.cpp; sourceTree = ""; }; + 37ACAEE61A15393A00D18B60 /* MyPushManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyPushManager.h; sourceTree = ""; }; + 37ACAEE71A15393A00D18B60 /* TestPushScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestPushScene.cpp; sourceTree = ""; }; + 37ACAEE81A15393A00D18B60 /* TestPushScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestPushScene.h; sourceTree = ""; }; + 37ACAF1C1A158D3800D18B60 /* libPluginGameThrivePush.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libPluginGameThrivePush.a; path = "../../../../../../Users/hiptic/Library/Developer/Xcode/DerivedData/plugin-x_ios-ghesvmhlqejqzueauxtbrhsuzcjp/Build/Products/Debug-iphoneos/libPluginGameThrivePush.a"; sourceTree = ""; }; + 37ACAF231A158ECE00D18B60 /* FBAudienceNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FBAudienceNetwork.framework; path = ../../../plugins/facebookads/proj.ios/FBAudienceNetwork.framework; sourceTree = ""; }; 591A8D2219DF4DB700F71BFD /* libPluginFacebook.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libPluginFacebook.a; sourceTree = BUILT_PRODUCTS_DIR; }; 591A8D2319DF4DB700F71BFD /* libPluginFacebookAds.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libPluginFacebookAds.a; sourceTree = BUILT_PRODUCTS_DIR; }; 592A55781964AD7D008E4BC7 /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; }; - 593E0BDC19BE206C00836D29 /* FBAudienceNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FBAudienceNetwork.framework; path = ../../../plugins/facebookads/proj.ios/FBAudienceNetwork.framework; sourceTree = ""; }; 59EB3BE91964A7DD0020118E /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; 59EB3BEB1964A86D0020118E /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; }; 7855E0DF153FEF240059DD9A /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = SOURCE_ROOT; }; @@ -191,6 +201,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 377A83A41AD7611300DE19B1 /* OneSignal.framework in Frameworks */, + 37ACAF241A158ECE00D18B60 /* FBAudienceNetwork.framework in Frameworks */, 591A8D2419DF4DB700F71BFD /* libPluginFacebook.a in Frameworks */, 591A8D2519DF4DB700F71BFD /* libPluginFacebookAds.a in Frameworks */, 59EB3BE719649CFC0020118E /* libcocos2d iOS.a in Frameworks */, @@ -199,7 +211,6 @@ D44C6210132DFF4E0009C878 /* AudioToolbox.framework in Frameworks */, D44C620E132DFF430009C878 /* AVFoundation.framework in Frameworks */, 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */, - 593E0BDD19BE206C00836D29 /* FBAudienceNetwork.framework in Frameworks */, FA848862182B3DEB00858BDD /* CoreMotion.framework in Frameworks */, 59EB3BEC1964A86D0020118E /* CoreTelephony.framework in Frameworks */, 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, @@ -222,6 +233,7 @@ FAD554F8177C16A100968F54 /* libPluginWeibo.a in Frameworks */, A964B98A19A1023500D96640 /* libsqlite3.dylib in Frameworks */, BF1712461292920000B8313A /* libxml2.dylib in Frameworks */, + 37ACAF1D1A158D3800D18B60 /* libPluginGameThrivePush.a in Frameworks */, BF1712471292920000B8313A /* libz.dylib in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -247,6 +259,7 @@ 15AA9C4015B7EC450033D6C2 /* Classes */ = { isa = PBXGroup; children = ( + 37ACAEE41A15393A00D18B60 /* TestPush */, 15CF33D319C0319E00D5614B /* TestFacebookShare */, 15CF33D619C0319E00D5614B /* TestFacebookUser */, FADBF89D179E559900F59B1D /* TestSocial */, @@ -310,10 +323,10 @@ 29B97323FDCFA39411CA2CEA /* Frameworks */ = { isa = PBXGroup; children = ( + 377A83A31AD7611300DE19B1 /* OneSignal.framework */, A964B98919A1023500D96640 /* libsqlite3.dylib */, A964B97D19A101BD00D96640 /* libPluginVungle.a */, 15CF33C919C029BF00D5614B /* FacebookSDK.framework */, - 593E0BDC19BE206C00836D29 /* FBAudienceNetwork.framework */, 592A55781964AD7D008E4BC7 /* GameController.framework */, 59EB3BEB1964A86D0020118E /* CoreTelephony.framework */, 59EB3BE91964A7DD0020118E /* Security.framework */, @@ -333,6 +346,7 @@ FAD554F2177C16A100968F54 /* libPluginWeibo.a */, BF170DB212928DE900B8313A /* libxml2.dylib */, BF170DB412928DE900B8313A /* libz.dylib */, + 37ACAF1C1A158D3800D18B60 /* libPluginGameThrivePush.a */, D44C620F132DFF4E0009C878 /* AudioToolbox.framework */, D44C620D132DFF430009C878 /* AVFoundation.framework */, 288765A40DF7441C002DB57D /* CoreGraphics.framework */, @@ -345,6 +359,18 @@ name = Frameworks; sourceTree = ""; }; + 37ACAEE41A15393A00D18B60 /* TestPush */ = { + isa = PBXGroup; + children = ( + 37ACAEE51A15393A00D18B60 /* MyPushManager.cpp */, + 37ACAEE61A15393A00D18B60 /* MyPushManager.h */, + 37ACAEE71A15393A00D18B60 /* TestPushScene.cpp */, + 37ACAEE81A15393A00D18B60 /* TestPushScene.h */, + ); + name = TestPush; + path = ../Classes/TestPush; + sourceTree = ""; + }; 78C7DDAA14EBA5050085D0C2 /* Resources */ = { isa = PBXGroup; children = ( @@ -566,10 +592,12 @@ 1AFCDA8216D4A25900906EA6 /* RootViewController.mm in Sources */, 15CF33D919C0319E00D5614B /* TestFacebookShare.cpp in Sources */, FAD554E5177C131500968F54 /* TestAdsScene.cpp in Sources */, + 37ACAEE91A15393A00D18B60 /* MyPushManager.cpp in Sources */, FAD554E6177C131500968F54 /* TestAnalyticsScene.cpp in Sources */, FAD554E9177C131500968F54 /* MyShareManager.cpp in Sources */, FAD554EA177C131500968F54 /* TestShareScene.cpp in Sources */, FAD55518177D1EE900968F54 /* MyPurchase.cpp in Sources */, + 37ACAEEA1A15393A00D18B60 /* TestPushScene.cpp in Sources */, FAD55519177D1EE900968F54 /* TestIAPScene.cpp in Sources */, FAD5551A177D1EE900968F54 /* MyUserManager.cpp in Sources */, 15CF33DA19C0319E00D5614B /* TestFacebookUserScene.cpp in Sources */, @@ -604,6 +632,9 @@ FRAMEWORK_SEARCH_PATHS = ( "\"$(SRCROOT)/../../../plugins/facebookads/proj.ios\"", "$(SRCROOT)/../../../plugins/facebook/proj.ios/sdk", + "$(SYSTEM_APPS_DIR)/cocos2d-x-3.3rc0/plugin/plugins/GameThrive/proj.ios/sdk", + "$(SYSTEM_APPS_DIR)/cocos2d-x-3.3rc0/plugin/plugins/facebookads/proj.ios", + "/Users/hiptic/Documents/OneSignal-Plugin-x/plugin-x/plugins/OneSignal/proj.ios/sdk", ); GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; @@ -621,7 +652,7 @@ HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; - LIBRARY_SEARCH_PATHS = ""; + LIBRARY_SEARCH_PATHS = "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/plugin-x_ios-ghesvmhlqejqzueauxtbrhsuzcjp/Build/Products/Debug-iphoneos"; OTHER_CFLAGS = "-O2"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = HelloPlugins; @@ -644,6 +675,9 @@ FRAMEWORK_SEARCH_PATHS = ( "\"$(SRCROOT)/../../../plugins/facebookads/proj.ios\"", "$(SRCROOT)/../../../plugins/facebook/proj.ios/sdk", + "$(SYSTEM_APPS_DIR)/cocos2d-x-3.3rc0/plugin/plugins/GameThrive/proj.ios/sdk", + "$(SYSTEM_APPS_DIR)/cocos2d-x-3.3rc0/plugin/plugins/facebookads/proj.ios", + "/Users/hiptic/Documents/OneSignal-Plugin-x/plugin-x/plugins/OneSignal/proj.ios/sdk", ); GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -659,7 +693,7 @@ HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; - LIBRARY_SEARCH_PATHS = ""; + LIBRARY_SEARCH_PATHS = "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/plugin-x_ios-ghesvmhlqejqzueauxtbrhsuzcjp/Build/Products/Debug-iphoneos"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = HelloPlugins; SDKROOT = iphoneos;