GVKun编程网logo

cocos2dx-lua3.12 IOS内购(cocos2d lua破解)

10

以上就是给各位分享cocos2dx-lua3.12IOS内购,其中也会对cocos2dlua破解进行解释,同时本文还将给你拓展(12)初学cocos2dxlua、Cocos2d-x3.9+VS2012

以上就是给各位分享cocos2dx-lua3.12 IOS内购,其中也会对cocos2d lua破解进行解释,同时本文还将给你拓展(12) 初学cocos2dx lua、Cocos2d-x 3.9 + VS2012 + BabeLua 如何搭建cocos2dx lua环境、cocos2d-x lua 屏幕适配问题(OpenGL调用),版本号(cocos2dx v3.4)、Cocos2d-X 学习笔记 13 cocos2dx ios 消息推送等相关知识,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

cocos2dx-lua3.12 IOS内购(cocos2d lua破解)

cocos2dx-lua3.12 IOS内购(cocos2d lua破解)

因为是用lua调用ios内购,所以就没有采用C++调用,而是直接用lua调用OC代码,所以就直接做的OC版,从网上找的OC支付代码,自己去调用。先说一下这个OC类的网址:http://download.csdn.net/detail/vkenchen/7219133

对接的过程中,遇到以下几个问题:

1) 当添加好OC类之后,编译的时候直接报“Cannot synthesize weak property infile using manual reference counting”这个错误,解决办法是在工程的buildsetting下,搜索Weak Reference in Manual Retain Release 将其设置为YES即可。

2) 因为网上的OC类只有核心代码,并没有直接调用的代码,所以就自己写的调用代码,这里不能直接去调用buy函数,如果直接调用的话,会发现回调函数收不到,所以之前一定要先进行注册,也就是OC类中的setup函数,然后在调用buy函数。

(12) 初学cocos2dx lua

(12) 初学cocos2dx lua

最基本的层

[plain] view plain copy
  1. functioncreateInGameLayer()
  2. localinGameLayer=cc.Layer:create()
  3. returninGameLayer
  4. end

最基本的场景

Cocos2d-x 3.9 + VS2012 + BabeLua 如何搭建cocos2dx lua环境

Cocos2d-x 3.9 + VS2012 + BabeLua 如何搭建cocos2dx lua环境

这几天一直在试一些cocos2dx lua的开发环境,试过cocos code ide 1.2和cocos code ide 2.0。前者莫名其妙软件崩
溃,后者却不支持lua的自动补齐和代码提示,只能回归vs2012了。
    本文就默认大家都下好了cocos2d-x3.9,其实cocos2d-x3.x都差不多,稍微有点区别。也默认大家都装好了BabeLua。我的
BabeLua不是1.x版本的,是3.x版本的。
我的BabeLua安装好后,会在VS2012控制面板出现一个Lua按钮,点击按钮后没有网上其他教程说的Lua Setting,这个没有
关系。
下面开始搭建环境:
    1.进入到cocos2dx3.9 源码包的tools/cocos2d-console/bin目录下,使用cocos new 项目名称 -p com.cocos.game
 -l lua -d 工程目录 这种方式来创建cocos2dxlua 项目。创建好的项目目录是这样的(我的项目名称是HelloLua003):
2.用VS2012打开刚刚创建的项目,注意入口是在frameworks/runtime-src/proj.win32
点击编译运行,会将之前的项目目录更新成如下所示:
新生成的simulator目录下有我们需要使用的模拟器HelloLua003.exe文件,这个在配置lua环境需要用到。
    3.点击VS2012上方的Lua按钮,选择new lua project,配置好后如下图所示:
下面对每个选择进行详细介绍
    Lua Project
    Lua scripts folder:选择Lua文件的保存位置,一般是src
    Lua exe path:选择模拟器的位置,在simulator/win32下面的.exe文件
    注意,在选择完Lua exe path 后会自动生成下面的Working path,默认是生成的simulator/win32,这个是错误的,改成
自己的项目目录
    Working path:工程目录,比如我的是E:\cocos2dx_proj\cocos2d_proj\cocos2dx_3.9_Lua_proj\HelloLua003
    Command line:输入-workdir 项目目录 -file src\main.lua,比如我的是-workdir E:\cocos2dx_proj\
cocos2d_proj\cocos2dx_3.9_Lua_proj\HelloLua003 -file src\main.lua
    Lua project name:可以随意自己定,比如我就直接写的Lua

    4.点击确认后会在vs上生成Lua工程目录
6.将Lua设置为启动项后点击运行,得到如下界面表示成功。
当然,我推荐使用sublime text2 来写代码,写好代码会自动同步到vs当中,然后使用vs编译查看效果。具体的sublime
 text2 配置cocos2dx lua api 环境,可以自行百度,网上教程很多。

cocos2d-x lua 屏幕适配问题(OpenGL调用),版本号(cocos2dx v3.4)

cocos2d-x lua 屏幕适配问题(OpenGL调用),版本号(cocos2dx v3.4)

前言

我们知道,cocos2dx 中屏幕适配的设置方法是

Director::getInstance()->getopenGLView()->setDesignResolutionSize(960,640,kResolutionShowAll);

为了保持我们的游戏不被拉伸,选择showAll方法。但是有一个问题,showAll会留黑边,那么我们只需要在openGL中渲染黑边即可。这样黑边就会被填充为我们自己设置的图片。话不多说,看看下面的代码。

MainScene.lua

调用示例如下,只需要在onEnter里面渲染即可

function MainScene:onEnter()

    local function createSpriteWithPathPosScale(path,pos)
    local sprite = cc.Sprite:create(path)
    sprite : setAnchorPoint(cc.p(0.5,0.5))
    sprite : setPosition(pos)
    return sprite
  end


  local frameSize = cc.Director:getInstance() : getopenGLView() : getFrameSize()
  local layer = cp.ScreenMatchLayer : create()
  layer:retain()


  local sprite = createSpriteWithPathPosScale("ui_img_left.jpg",cc.p(-44,320))
  layer : getChildByName("_node") : addChild(sprite)


  sprite = createSpriteWithPathPosScale("ui_img_right.jpg",cc.p(960 + 44,320))
  layer : getChildByName("_node") : addChild(sprite)


  sprite = createSpriteWithPathPosScale("ui_img_top.jpg",cc.p(480,640 + 32.5))
  layer : getChildByName("_node") : addChild(sprite)


  sprite = createSpriteWithPathPosScale("ui_img_down.jpg",-32.5))
  layer : getChildByName("_node") : addChild(sprite)
end


AppDelegate.cpp

这里面对ScreenMatchLayer进行注册以便被lua调用

bool AppDelegate::applicationDidFinishLaunching()
{
    // set default FPS
    Director::getInstance()->setAnimationInterval(1.0 / 60.0f);
   
    // register lua module
    auto engine = LuaEngine::getInstance();
    ScriptEngineManager::getInstance()->setScriptEngine(engine);
    lua_State* L = engine->getLuaStack()->getLuaState();
    lua_module_register(L);
	ScreenMatchLayer::lua_bind_AllFunction(L);

    // If you want to use Quick-Cocos2d-X,please uncomment below code
    // register_all_quick_manual(L);

    LuaStack* stack = engine->getLuaStack();
    stack->setXXTEAKeyAndSign("2dxLua",strlen("2dxLua"),"XXTEA",strlen("XXTEA"));
    
    //register custom function
    //LuaStack* stack = engine->getLuaStack();
    //register_custom_function(stack->getLuaState());
    
#if (COCOS2D_DEBUG > 0) && (CC_CODE_IDE_DEBUG_SUPPORT > 0)
    // NOTE:Please don't remove this call if you want to debug with Cocos Code IDE
    RuntimeEngine::getInstance()->start();
    cocos2d::log("iShow!");
#else
    if (engine->executeScriptFile("src/main.lua"))
    {
        return false;
    }
#endif
    
    return true;
}



ScreenMatchLayer.h


#ifndef __SCREENMATCHLAYER_H__
#define __SCREENMATCHLAYER_H__

#include "cocos2d.h"

namespace cocos2d{

	class ScreenMatchLayer : public  Layer
	{
	public:
		ScreenMatchLayer(void);
		~ScreenMatchLayer(void);
		static ScreenMatchLayer* create();
		bool init();

		void visit(Renderer *renderer,const Mat4& parentTransform,uint32_t parentFlags);
		void onBeforeVisit();
		void onAfterVisit();

		static int  lua_bind_AllFunction(lua_State* tolua_S);
		static const std::string classprefix;
		static const std::string fullName;
		static const std::string className;
	private:
		Node* _node;
		CustomCommand _beforeVisit;
		CustomCommand _afterVisit;
	};
}

int lua_cocos2dx_ScreenMatchLayer_create(lua_State* tolua_S);
#endif

ScreenMatchLayer.cpp

#include "ScreenMatchLayer.h"
#include "tolua_fix.h"
#include "LuaBasicConversions.h"
using namespace cocos2d;

const std::string ScreenMatchLayer::classprefix = "cp";
const std::string ScreenMatchLayer::className = "ScreenMatchLayer";
const std::string ScreenMatchLayer::fullName = classprefix + "." + className;

ScreenMatchLayer::ScreenMatchLayer(void)
{
}


ScreenMatchLayer::~ScreenMatchLayer(void)
{
}

bool ScreenMatchLayer::init()
{
	if ( !Layer::init() ) {
		return false;
	}
	
	_node = Node::create();
	_node->setName("_node");
	_node->setAnchorPoint(ccp(0,0));
	addChild(_node);

	GLView* openGLView = this->_director->getopenGLView();
	Size frameSize = openGLView->getFrameSize();
	Size designSize = Size(960,640); 

	Size nodeSize = Size(0,0);

	bool frameSizeWidthLarger = (designSize.width / designSize.height) < (frameSize.width / frameSize.height );
	
	if(frameSizeWidthLarger)
	{
		nodeSize.height = designSize.height;
		nodeSize.width = nodeSize.height * (frameSize.width / frameSize.height);
	}
	else
	{
		nodeSize.width = designSize.width;
		nodeSize.height = nodeSize.width * (frameSize.height / frameSize.width);
	}
 	 _node->setPosition(ccp((nodeSize.width - designSize.width) / 2,(nodeSize.height - designSize.height) / 2));

	auto _afterDrawListener = EventListenerCustom::create(Director::EVENT_AFTER_VISIT,[this](EventCustom* event) {
			this->visit(this->_director->getRenderer(),Mat4::IDENTITY,0);
	});
	auto eventdispatcher = Director::getInstance()->getEventdispatcher();
	eventdispatcher->addEventListenerWithFixedPriority(_afterDrawListener,1);

	return true;
}

void ScreenMatchLayer::onBeforeVisit()
{
	GLView* openGLView = this->_director->getopenGLView();
	Size frameSize = openGLView->getFrameSize();
	glViewport((GLint)(0),(GLint)(0),(GLsizei)(frameSize.width),(GLsizei)(frameSize.height));
}

void ScreenMatchLayer::onAfterVisit()
{
	GLView* openGLView = this->_director->getopenGLView();
	Size designSize = openGLView->getDesignResolutionSize();
	openGLView->setViewPortInPoints(0,designSize.width,designSize.height);
}

void ScreenMatchLayer::visit(Renderer *renderer,uint32_t parentFlags)
{
	if(!_visible)
        return;

    _beforeVisit.init(_globalZOrder);
    _beforeVisit.func = CC_CALLBACK_0(ScreenMatchLayer::onBeforeVisit,this);
    renderer->addCommand(&_beforeVisit);

	Node::visit(renderer,parentTransform,parentFlags);
    
    _afterVisit.init(_globalZOrder);
    _afterVisit.func = CC_CALLBACK_0(ScreenMatchLayer::onAfterVisit,this);
    renderer->addCommand(&_afterVisit);
}

ScreenMatchLayer * ScreenMatchLayer::create()
{
	ScreenMatchLayer *pRet = new ScreenMatchLayer();
	if ( pRet && pRet->init() ) {
        pRet->autorelease();
        return pRet;
    }
    CC_SAFE_DELETE(pRet);
    return nullptr;
}

int ScreenMatchLayer::lua_bind_AllFunction(lua_State* tolua_S)
{
		lua_getglobal(tolua_S,"_G");
		if (lua_istable(tolua_S,-1))//stack:...,_G,{
			tolua_open(tolua_S);
		
			tolua_module(tolua_S,classprefix.c_str(),0);
			tolua_beginmodule(tolua_S,classprefix.c_str());

			tolua_usertype(tolua_S,ScreenMatchLayer::fullName.c_str());
			tolua_cclass(tolua_S,className.c_str(),ScreenMatchLayer::fullName.c_str(),"cc.Layer",nullptr);

			tolua_beginmodule(tolua_S,className.c_str());
				tolua_function(tolua_S,"create",lua_cocos2dx_ScreenMatchLayer_create);
			tolua_endmodule(tolua_S);
			g_luaType[typeid(ScreenMatchLayer).name()] = ScreenMatchLayer::fullName;
			g_typeCast[className] = ScreenMatchLayer::fullName;
			
			tolua_endmodule(tolua_S);
		}
		lua_pop(tolua_S,1);
	return 1;
}

int lua_cocos2dx_ScreenMatchLayer_create(lua_State* tolua_S)
{
    int argc = 0;
	ScreenMatchLayer* parentOfFunction = nullptr;
	const std::string &functionString = "'lua_cocos2dx_ScreenMatchLayer_create'";
	const std::string &luaFunctionString = ScreenMatchLayer::fullName + ":create";

#if COCOS2D_DEBUG >= 1
	tolua_Error tolua_err;
	if (!tolua_isusertable(tolua_S,1,&tolua_err))
	{
		  tolua_error(tolua_S,("#ferror in function " + functionString).c_str(),&tolua_err);
		  return 0;
	}

	parentOfFunction = (ScreenMatchLayer*)tolua_tousertype(tolua_S,0);
	 if (!parentOfFunction) 
    {
		//tolua_error(tolua_S,("invalid 'cobj' in function " + functionString).c_str(),nullptr);
        //return 0;
    }
#endif

    argc = lua_gettop(tolua_S) - 1;

    if (argc == 0)
    {
		ScreenMatchLayer* ret = ScreenMatchLayer::create();
        object_to_luaval<ScreenMatchLayer>(tolua_S,(ScreenMatchLayer*)ret);
        return 1;
    }
    else 	
	{luaL_error(tolua_S,"%s has wrong number of arguments: %d,was expecting %d \n",luaFunctionString.c_str(),argc,1);}
    return 0;

}

Cocos2d-X 学习笔记 13 cocos2dx ios 消息推送

Cocos2d-X 学习笔记 13 cocos2dx ios 消息推送

前言

使用推送消息,可提醒用户,召回玩家。延长游戏的寿命和收益!下面我们就一起来学习,cocos2d-x iOS集成push。

收到push消息:

本文主要内容:

1. iOS Push基本理念

2. 创建工程

3. ios push相关配置

4. push集成

5. push 测试和使用

6. 总结

7. 相关资料

iOS Push基本理念

我们先来了解,iOS push实现的大概原理

从上图我们可以看到。

1. 首先是应用程序注册消息推送。

2. IOS跟APNS Server要devicetoken。应用程序接受devicetoken。

3. 应用程序将devicetoken发送给PUSH服务端程序。

4. 服务端程序向APNS服务发送消息。

5. APNS服务将消息发送给iPhone应用程序。

无论是iPhone客户端跟APNS,还是Provider和APNS都需要通过证书进行连接的

创建工程

工程基于 cocos2d-x-3.0rc2 版本,针对ios平台.

cocos2d-x-3.0rc2 下载地址,如果已经有cocos2d-x 引擎可以跳过下载。解压文件进入该目录 创建工程

 
 
  1. $cdcocos2d-x
  2. $./setup.py
  3. $sourceFILE_TO_SAVE_SYstem_VARIABLE
  4. $cocosnewpushDemo-pcom.your_company.pushDemo-lcpp-d/home
  5. $cd/home/pushDemo

push相关配置

登陆iOS Dev Center选择进入iOS Provisioning Portal。创建应用程序ID

在 iOS Provisioning Portal中,点击App IDs进入App ID列表。

创建 App ID,如果 ID 已经存在可以直接跳过此步骤

为 App 开启 Push Notification 功能。如果是已经创建的 App ID 也可以通过设置开启 Push Notification 功能。

根据实际情况完善 App ID 信息并提交,注意此处需要指定具体的 Bundle ID 不要使用通配符。

push cer创建 develop 和 production 如果你之前没有创建过 Push 证书或者是要重新创建一个新的,请在证书列表下面新建。

新建证书需要注意选择证书种类(开发证书用于开发和调试使用,生产证书用于 App Store 发布)

点击 Continue 后选择证书对应的应用ID,然后继续会出现“About Creating a Certificate Signing Request (CSR)”。

根据它的说明创建打开KeychainAccess 创建 Certificate Signing Request。

填写“User Email Address”和“Common Name” 后选择 Saved to disk 进行保存 。

继续返回Apple developer 网站点击 Continue ,上传刚刚生成的 .certSigningRequest 文件生成 APNs Push Certificate。 下载并双击打开证书,证书打开时会启动“钥匙串访问”工具。 在“钥匙串访问”中你的证书会显示在“我的证书”中,注意选择“My Certificates” 和"login" 。

导出 .p12 证书文件 在“钥匙串访问”中,选择刚刚加进来的证书,选择右键菜单中的“导出“...””。 注意要选“login”和“My Certificates” 导出证书时要选中证书文件,不要展开private key。

将文件保存为Personal information Exchange (.p12)格式。 保存p12文件时,可以为其设置密码,也可以让密码为空。

app Provisioning Profile 创建,选取app Id,Certificates,Devices. 分develop 和 production

push集成

新建pushHelper C++类,定义监听push回调相关的接口。

  
  
  • classpushHelper
  • {
  • public:
  • /**returnsasharedinstanceofthepushHelper
  • *@jsgetInstance
  • */
  • staticpushHelper*sharedPushHelper(void);
  • /**
  • @briefThefunctionbecalledwhentheapplicationlaunchingreceiveremotenotification
  • @paramnotificationjsonthepointerofthenotificationjsonstring
  • */
  • boolapplicationDidFinishLaunchingWithNotification(constchar*notificationjson);
  • /**
  • @briefThefunctionbecalledwhentheapplicationregisterremotenotificationsuccess
  • @paramdevicetokenthepointerofthenotificationtokenstring
  • voidapplicationDidRegisterForRemoteNotificationsWithDevicetoken(char*devicetoken);
  • @briefThefunctionbecalledwhentheapplicationregisterremotenotificationFailed
  • @paramerrorthepointeroftheregisterremotenotificationFailedstring
  • */
  • voidapplicationdidFailToRegisterForRemoteNotificationsWithError(char*error);
  • @briefThefunctionbecalledwhentheapplicationrunningreceiveremotenotification
  • @paramnotificationjsonthepointerofthenotificationjsonstring
  • voidapplicationDidReceiveRemoteNotification(char*notificationjson);
  • };
  • 在AppController.mm加入 ios remoteNotification 相关实现

    1.在application: didFinishLaunchingWithOptions:注册push的种类,并处理启动时收到push

      
      
  • //======================push========================
  • [applicationregisterForRemoteNotificationTypes:
  • UIRemoteNotificationTypeAlert
  • |UIRemoteNotificationTypeBadge
  • |UIRemoteNotificationTypeSound];
  • [applicationsetApplicationIconBadgeNumber:0];
  • //启动时收到pushdelay5s派发
  • NSDictionary*userInfo=[launchOptionsobjectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
  • if(userInfo){
  • [applicationsetApplicationIconBadgeNumber:0];
  • NSLog(@"LaunchOptionsRemoteNotification:%@",[userInfodescription]);
  • dispatch_after(dispatch_time(disPATCH_TIME_Now,(int64_t)(5*NSEC_PER_SEC)),dispatch_get_main_queue(),^{
  • pushHelper::sharedPushHelper()->applicationDidFinishLaunchingWithNotification([[userInfodescription]cStringUsingEncoding:NSUTF8StringEncoding]);
  • });
  • }
  • //======================push========================
  • 2.在application: didRegisterForRemoteNotificationsWithDevicetoken:处理收到注册push成功返回的device token:

      
      
  • NSLog(@"pushdevicetoken:%@",devicetoken);
  • pushHelper::sharedPushHelper()->applicationDidRegisterForRemoteNotificationsWithDevicetoken([[devicetokendescription]cStringUsingEncoding:NSUTF8StringEncoding]);
  • 3.在application: didReceiveRemoteNotification: 处理app运行状态下接收到的Push消息:

      
      
  • NSLog(@"ReceiveNotify:%@",[userInfodescription]);
  • [applicationsetApplicationIconBadgeNumber:0];
  • pushHelper::sharedPushHelper()->applicationDidReceiveRemoteNotification([[userInfodescription]cStringUsingEncoding:NSUTF8StringEncoding]);
  • 4.在application: didFailToRegisterForRemoteNotificationsWithError:处理注册push失败

      
      
  • pushHelper::sharedPushHelper()->applicationdidFailToRegisterForRemoteNotificationsWithError([[errordescription]cStringUsingEncoding:NSUTF8StringEncoding]);
  • 实现pushHelper.cpp

    在cocos2dx 3.0的版本中 CCNotificationCenter 被废弃。我们 使用自定义事件进行推送通知派发。

      
      
  • boolpushHelper::applicationDidFinishLaunchingWithNotification(char*notificationjson)
  • {cclOG("applicationDidFinishLaunchingWithNotification=%s",notificationjson);
  • dispatcherNotificationEvent(notificationjson,NOTIFICATION_EVENT);
  • returntrue;
  • }
  • voidpushHelper::applicationDidRegisterForRemoteNotificationsWithDevicetoken(char*devicetoken)
  • {cclOG("applicationDidRegisterForRemoteNotificationsWithDevicetoken=%s",devicetoken);
  • dispatcherNotificationEvent(devicetoken,REGISTER_NOTIFICATION_DEVICetoKEN_EVENT);
  • }
  • voidpushHelper::applicationdidFailToRegisterForRemoteNotificationsWithError(char*error)
  • {cclOG("FailToRegisterForRemoteNotificationsWithError=%s",error);
  • dispatcherNotificationEvent(error,REGISTER_NOTIFICATION_ERROR_EVENT);
  • }
  • voidpushHelper::applicationDidReceiveRemoteNotification(char*notificationjson)
  • {cclOG("applicationDidReceiveRemoteNotification=%s",notificationjson);
  • dispatcherNotificationEvent(notificationjson,NOTIFICATION_EVENT);
  • }
  • voidpushHelper::dispatcherNotificationEvent(char*data,char*notificationEventType)
  • {
  • autodirector=Director::getInstance();
  • char*buf=newchar[256];
  • sprintf(buf,"%s",data);
  • EventCustomevent(notificationEventType);
  • event.setUserData(buf);
  • director->getEventdispatcher()->dispatchEvent(&event);
  • CC_SAFE_DELETE_ARRAY(buf);
  • }
  • push测试

    push 消息的推送 需要客户端和服务器的支持。自己搭建推送服务器(对于没有服务器编程经验的人)比较麻烦。现在国内主流的第三方push方案(百度云推送、极光推送、个推),都提供push集成客户端SDK 和 push消息推送控制台 或 消息推送服务SDK,推送结果统计。根据应用ID注册,消息推送条数 决定收费。开发者可以灵活选择使用。在此,本demo使用免费百度云推送方案,使用百度云推送的推送控制台测试。

    集成百度云推送

    1.上百度开发者注册工程

    2.参照文档完成客户端SDK的集成,加入baidu 云推送 依赖的framework

    3.完善工程配置,develop / production选择,上传APNS证书

    4.使用百度云推送控制台推送push

    push使用

    在想使用推送通知消息的地方加入监听推送通知事件的代码:

    在HelloWorldScene.cpp中监听remoteNotification

    //listen&handlepushmessage
      
      
  • voidHelloWorld::onEnter()
  • {
  • addNotificationListener();
  • }
  • voidHelloWorld::onExit()
  • {
  • removeNotificationListener();
  • }
  • voidHelloWorld::addNotificationListener()
  • {
  • notification_listener=EventListenerCustom::create(NOTIFICATION_EVENT,[=](EventCustom*event){
  • char*buf=static_cast<char*>(event->getUserData());
  • cclOG("Notification=%s",buf);
  • });
  • _eventdispatcher->addEventListenerWithFixedPriority(notification_listener,1);
  • register_notification_devicetoken_listener=EventListenerCustom::create(REGISTER_NOTIFICATION_DEVICetoKEN_EVENT,153); background-color:inherit; font-weight:bold">char*>(event->getUserData());
  • cclOG("registernotificationdevicetoken=%s",buf);
  • });
  • _eventdispatcher->addEventListenerWithFixedPriority(register_notification_devicetoken_listener,1);
  • register_notification_error_listener=EventListenerCustom::create(REGISTER_NOTIFICATION_ERROR_EVENT,153); background-color:inherit; font-weight:bold">char*>(event->getUserData());
  • cclOG("registernotificationerror=%s",buf);
  • });
  • _eventdispatcher->addEventListenerWithFixedPriority(register_notification_error_listener,1);
  • }
  • voidHelloWorld::removeNotificationListener()
  • {
  • _eventdispatcher->removeEventListener(notification_listener);
  • _eventdispatcher->removeEventListener(register_notification_devicetoken_listener);
  • _eventdispatcher->removeEventListener(register_notification_error_listener);
  • }
  • push运行结果

    1.获取device Token成功 绑定百度云推送成功

    2.收到push消息

    3.系统通知栏显示

    后记

    本demo 基于3.0 rc2版本实现,但是使用其他版本集成push功能与之类似,没有太大变化。 开发者可以灵活选择。 push 消息的处理 和 使用第三方推送SDK集成也可以灵活选择。

    总结

    以上是小编为你收集整理的Cocos2d-X 学习笔记 13 cocos2dx ios 消息推送全部内容。

    如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

    Cocos2d-x相关文章

    如何使用CCRenderTexture创建动态纹理 Cocos2d-x 2 1 4
        本文实践自 RayWenderlich、Ali Hafizji 的文章《How To Create Dynamic Textures with CCRenderTexture in Cocos2D 2.X》,文中使用Cocos2D,我在这里使用Cocos2D-x 2.1.4进行学习和移植。在这篇文章,将会学习到如何创建实时纹理、如何用Gimp创建无缝拼接纹
    Cocos-code-ide使用入门学习
    Cocos-code-ide使用入门学习地点:杭州滨江邮箱:appdevzw@163.com微信公众号:HopToad 欢迎转载,转载标注出处:http://blog.csdn.netotbaron/article/details/424343991.  软件准备 下载地址:http://cn.cocos2d-x.org/download 2.  简介2.1         引用C
    Cocos2D-x-3.0 编译(Win7)
    第一次開始用手游引擎挺激动!!!进入正题。下载资源1:从Cocos2D-x官网上下载,进入网页http://www.cocos2d-x.org/download,点击Cocos2d-x以下的Download  v3.0,保存到自定义的文件夹2:从python官网上下载。进入网页https://www.python.org/downloads/,我当前下载的是3.4.0(当前最新
    Cocos2d-x 2 0 在Windows平台下的使用
        Cocos2d-x是一款强大的基于OpenGLES的跨平台游戏开发引擎,易学易用,支持多种智能移动平台。官网地址:http://cocos2d-x.org/当前版本:2.0    有很多的学习资料,在这里我只做为自己的笔记记录下来,错误之处还请指出。在VisualStudio2008平台的编译:1.下载当前稳
    quick-cocos2d-x实例之挑战记忆极限设计文档
    1.  来源 QuickV3sample项目中的2048样例游戏,以及最近《最强大脑》娱乐节目。将2048改造成一款挑战玩家对数字记忆的小游戏。邮箱:appdevzw@163.com微信公众号:HopToadAPK下载地址:http://download.csdn.net/detailotbaron/8446223源码下载地址:http://download.csdn.net/
    Cocos2d-x 3 X CMake MinGW版本编译运行
       Cocos2d-x3.x已经支持使用CMake来进行构建了,这里尝试以QtCreatorIDE来进行CMake构建。Cocos2d-x3.X地址:https://github.com/cocos2d/cocos2d-x1.打开QtCreator,菜单栏→"打开文件或项目...",打开cocos2d-x目录下的CMakeLists.txt文件;2.弹出CMake向导,如下图所示:设置
    vs 2013 编译cocos2d-x-3.9
     下载地址:链接:https://pan.baidu.com/s/1IkQsMU6NoERAAQLcCUMcXQ提取码:p1pb下载完成后,解压进入build目录使用vs2013打开工程设置平台工具集,打开设置界面设置: 点击开始编译等待编译结束编译成功在build文件下会出现一个新文件夹Debug.win32,里面就是编译
    cocos2d-x游戏开发系列教程-超级玛丽01-前言
    分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!http://www.captainbed.net前言上次用象棋演示了cocos2dx的基本用法,但是对cocos2dx并没有作深入的讨论,这次以超级马里奥的源代码为线索,我们一起来学习超级马里奥的实
    • • 如何使用CCRenderTexture创建动态纹理
    • • Cocos-code-ide使用入门学习
    • • Cocos2D-x-3.0 编译(Win7)
    • • Cocos2d-x 2 0 在Windows平台下的使用
    • • quick-cocos2d-x实例之挑战记忆极限设计
    • • Cocos2d-x 3 X CMake MinGW版本编译运行
    • • vs 2013 编译cocos2d-x-3.9
    • • cocos2d-x游戏开发系列教程-超级玛丽01
    • • Cocos2d-x CCControlPotentiometer之圆
    • • Cocos2d-x入门教程(二)简单的静态显示
    Flutterandroidiosswift抖音cocos2d小米cocos2dx三国杀kotlin-coroppococosandroid-jexcodeandroid-liaugmented-美好mutateandroid-gr加到arkitreact-naticnnandroid-cocrashlytic耳机java-nativexoplayerstockandroid-ar壁纸react-natiandroid-daandroid-wowatchosandroid-ca笔记本电脑buildozer装备android-al
    • 友情链接:
    • 菜鸟教程
    • 前端之家
    • 编程小课
    • 小编
    • -
    • 我要投稿
    • -
    • 广告合作
    • -
    • 联系我们
    • -
    • 免责声明
    • -
    • 网站地图
    版权所有 © 2018 小编 闽ICP备13020303号-8
    微信公众号搜索 “ 程序精选 ” ,选择关注!
    微信公众号搜"程序精选"关注
    微信扫一扫可直接关注哦!

    今天的关于cocos2dx-lua3.12 IOS内购cocos2d lua破解的分享已经结束,谢谢您的关注,如果想了解更多关于(12) 初学cocos2dx lua、Cocos2d-x 3.9 + VS2012 + BabeLua 如何搭建cocos2dx lua环境、cocos2d-x lua 屏幕适配问题(OpenGL调用),版本号(cocos2dx v3.4)、Cocos2d-X 学习笔记 13 cocos2dx ios 消息推送的相关知识,请在本站进行查询。

    本文标签:

    上一篇不是每个捕鱼都叫捕鱼达人:Cocos精品《捕鱼达人4》华丽升级(cocos2dx捕鱼达人)

    下一篇cocos creator 事件集合(cocos creator schedule)