ios开发推送证书配置好怎么使用

ios开发推送证书配置好怎么使用,第1张

推送部分是自己的服务器做还是第三方,比如JPush 或者环信等等,如果是自己的服务器就要看是php ,还是java 或者是net 根据相应的服务器环境提供相关的PEM文件给服务器端配置使用。如果是Jpush 好像需要上传P12文件,环信好像也是P12 具体对应相应的sdk接入文档去看

import javaawtColor;

import javaawtDimension;

import javaawtFont;

import javaawteventActionEvent;

import javaawteventActionListener;

import javaawteventKeyEvent;

import javaawteventKeyListener;

import javaioIOException;

import javanetDatagramPacket;

import javanetDatagramSocket;

import javanetInetAddress;

import javaxswingJButton;

import javaxswingJFrame;

import javaxswingJPanel;

import javaxswingJScrollPane;

import javaxswingJSplitPane;

import javaxswingJTextArea;

public class ChatFrame extends JPanel{

private static final long serialVersionUID = 1L;

private int width=450,height=450;

boolean flag;

int port = 10086;

String address = "1921683352";

// int port = 2425;

DatagramSocket send;

DatagramSocket receive;

UDP_Send udpSend;

JTextArea showTextArea;

JTextArea inputTextArea;

JPanel rightPanel;

JScrollPane scrollPane1;

JScrollPane scrollPane2;

JSplitPane splitPane1;

JSplitPane splitPane2;

JButton sendButton;

JButton closeButton;

JPanel buttonpane;

public ChatFrame() throws Exception {

super(null, true);

send = new DatagramSocket();

receive = new DatagramSocket(port);

udpSend =new UDP_Send(send,port);

showTextArea = new JTextArea();

showTextAreasetLineWrap(true);

showTextAreasetEditable(false);

showTextAreasetForeground(new Color(0xf90033));

scrollPane1 = new JScrollPane(showTextArea);

inputTextArea = new JTextArea();

inputTextAreasetLineWrap(true);

scrollPane2 = new JScrollPane(inputTextArea);

rightPanel = new JPanel();

rightPanelsetBackground(new Color(0x0099ff));

splitPane1 = new JSplitPane(JSplitPaneVERTICAL_SPLIT,true,scrollPane1,scrollPane2);

splitPane2 = new JSplitPane(JSplitPaneHORIZONTAL_SPLIT,true,splitPane1,rightPanel);

inputTextAreaaddKeyListener(new KeyListener() {

@Override

public void keyTyped(KeyEvent e) {}

@Override

public void keyReleased(KeyEvent e) {}

@Override

public void keyPressed(KeyEvent e) {

switch (egetKeyCode()) {

case KeyEventVK_ENTER:

udpSendsend(port);

inputTextAreasetText("");

break;

default:

break;

}

}

});

sendButton = new JButton("发送");

sendButtonaddActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

udpSendsend(port);

inputTextAreasetText("");

}

});

closeButton = new JButton("关闭");

closeButtonaddActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

Systemexit(0);

}

});

buttonpane = new JPanel();

buttonpaneadd(closeButton);

buttonpaneadd(sendButton);

splitPane1setBounds(0, 0, width, height-32);

splitPane1setDividerLocation(08);

splitPane2setBounds(0, 0, width, height-32);

splitPane2setDividerLocation(08);

buttonpanesetBounds(width-250, height-32, 140, 32);

thisadd(splitPane2);

thisadd(buttonpane);

thissetPreferredSize(new Dimension(width,height));

new Thread(new UDP_Receive(receive))start();

}

public static void main(String[] args) throws Exception {

JFrame frame = new JFrame();

framesetContentPane(new ChatFrame());

framepack();

framesetResizable(false);

framesetLocationRelativeTo(null);

framesetDefaultCloseOperation(JFrameEXIT_ON_CLOSE);

framesetVisible(true);

}

class UDP_Send{

DatagramSocket datagramSocket;

int port;

String text;

public UDP_Send(DatagramSocket datagramSocket,int port) {

thisdatagramSocket = datagramSocket;

thisport = port;

}

public void send(int port) {

try {

text = new String(inputTextAreagetText()getBytes(), "utf-8");

byte buffered[] = textgetBytes();

DatagramPacket database = new DatagramPacket(buffered,

bufferedlength, InetAddressgetByName(address),port) ;

showTextAreasetFont(new Font("微软雅黑", FontCENTER_BASELINE, 24));

showTextAreaappend("本机"+":\n");

showTextAreasetFont(new Font("仿宋", FontCENTER_BASELINE, 16));

showTextAreaappend(" "+text+"\n");

datagramSocketsend(database);

} catch (IOException e) {

eprintStackTrace();

}

}

}

class UDP_Receive implements Runnable {

DatagramSocket datagramSocket;

public UDP_Receive(DatagramSocket datagramSocket) {

thisdatagramSocket = datagramSocket;

}

@Override

public void run() {

try {

byte buff[] = new byte[4096];

DatagramPacket database = new DatagramPacket(buff, bufflength);

while (true) {

datagramSocketreceive(database);

String text = new String(databasegetData(), 0,databasegetLength(),"utf-8");

showTextAreasetFont(new Font("微软雅黑", FontCENTER_BASELINE, 24));

showTextAreaappend(databasegetAddress()+":\n");

showTextAreasetFont(new Font("仿宋", FontCENTER_BASELINE, 16));

showTextAreaappend(" "+text+"\n");

}

} catch (IOException e) {

eprintStackTrace();

}

}

}

}

程序在这句把args初始化为一个有10个元素的String数组,然后在下一句,马上把args的第一个元素转换为整型,这时args[0]肯定是null,所以报了转换错误。

客户端也是同样的问题

我给你一个类似的代码,你自己改一下就可以了,我不给你该了。希望对你有所帮助!

<----------------------服务器端------------------------------->

//实现多线程的网络连接

package cnsocket;

import javaio;

import javanet;

public class SocketServerTrue {

public SocketServerTrue()

{

try {

//服务器开启一个端口

Systemoutprintln("等待连接");

ServerSocket ss= new ServerSocket(8090);

//等待连接,返回socket类型的对象

Socket s=ssaccept();

Systemoutprintln("连接成功,等待客户端输入信息!");

//得到客户端的信息

InputStreamReader isr=new InputStreamReader(sgetInputStream());

BufferedReader br=new BufferedReader(isr);

//向客户端传递信息

PrintWriter pw=new PrintWriter(sgetOutputStream(),true);

//实现从控制台输入数据

InputStreamReader isrS=new InputStreamReader(Systemin);

BufferedReader brS=new BufferedReader(isrS);

while(true)

{

//得到客户端的信息

String info=brreadLine();

//判断是否结束

if(infoequals("bye"))

{

Systemoutprintln("对话结束!");

sclose();

break;

}

Systemoutprintln("对方说:"+info);

//给客户端传递信息

String infoC=brSreadLine();

pwprintln(infoC);

if(infoCequals("bye"))

{

Systemoutprintln("对话结束!");

sclose();

break;

}

}

} catch (IOException e) {

// TODO Auto-generated catch block

eprintStackTrace();

}

}

/

@param args

/

public static void main(String[] args) {

// TODO Auto-generated method stub

SocketServerTrue ssm=new SocketServerTrue();

}

}

<---------------------------客户端-------------------------->

//客户端的(多线程)

package cnsocket;

import javaio;

import javanet;

public class SocketClientTrue {

public SocketClientTrue()

{

//去连接服务器

try {

Socket s=new Socket("127001",8090);

Systemoutprintln("连接成功,给服务器说话!");

//向服务器传递的信息

PrintWriter pw=new PrintWriter(sgetOutputStream(),true);

//得到服务器信息

InputStreamReader isr=new InputStreamReader(sgetInputStream());

BufferedReader br=new BufferedReader(isr);

//从控制台输入信息

InputStreamReader isrC=new InputStreamReader(Systemin);

BufferedReader brC=new BufferedReader(isrC);

while(true)

{

//给服务器说话

String infoS=brCreadLine();

pwprintln(infoS);

if(infoSequals("bye"))

{

Systemoutprintln("对话结束!");

sclose();

break;

}

//得到服务器的信息

String info=brreadLine();

if(infoequals("bye"))

{

Systemoutprintln("对话结束!");

sclose();

break;

}

Systemoutprintln("对方说:"+info);

}

} catch (UnknownHostException e) {

// TODO Auto-generated catch block

eprintStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

eprintStackTrace();

}

}

/

@param args

/

public static void main(String[] args) {

// TODO Auto-generated method stub

SocketClientTrue scm=new SocketClientTrue();

}

}

;

DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
网站模板库 » ios开发推送证书配置好怎么使用

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情