Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
OffcnIMSDKiOS
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
opensource
OffcnIMSDKiOS
Commits
12769036
Commit
12769036
authored
Aug 28, 2020
by
zhangyunjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
推送
parent
5d46688b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
4 deletions
+30
-4
AppDelegate.m
OffcnIMSDKiOS/AppDelegate.m
+22
-2
OffcnIMSocketManager.h
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMSocketManager.h
+3
-1
OffcnIMSocketManager.m
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMSocketManager.m
+5
-1
No files found.
OffcnIMSDKiOS/AppDelegate.m
View file @
12769036
...
...
@@ -9,6 +9,7 @@
#import "AppDelegate.h"
#import "ViewController.h"
#import "OffcnIMSDKiOS.h"
#import "OffcnIMSocketManager.h"
@interface
AppDelegate
()
...
...
@@ -56,12 +57,22 @@
-
(
void
)
applicationDidBecomeActive
:(
UIApplication
*
)
application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
if
([
OffcnIMSocketManager
defaultService
].
IMConnectStatus
!=
OffcnIMConnectStatusSuccess
)
{
//建立连接
NSString
*
paramStr
=
@"{
\"
server_ip
\"
:
\"
192.168.43.141
\"
,
\"
server_port
\"
:1026,
\"
account_id
\"
:
\"
ce0819db8391f1e7258a71cc9e2c3235
\"
,
\"
app_id
\"
:
\"
offcn_live
\"
,
\"
device_type
\"
:
\"
ios
\"
,
\"
token
\"
:
\"
fadbce3f4929b6bdee0617fee34e32ae
\"
,
\"
session_id
\"
:
\"
123
\"
,
\"
connection_type
\"
:
\"
websocket
\"
,
\"
tls
\"
:
\"
disable
\"
}"
;
[[
OffcnIMSocketManager
defaultService
]
connectIMServerWithParam
:
paramStr
];
}
//进入前台,清除推送角标
[
UIApplication
sharedApplication
].
applicationIconBadgeNumber
=
0
;
[
application
cancelAllLocalNotifications
];
// [JPUSHService setBadge:0];
}
-
(
void
)
applicationWillTerminate
:(
UIApplication
*
)
application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
//断开连接
[[
OffcnIMSocketManager
defaultService
]
disConnectIMServer
];
}
...
...
@@ -131,6 +142,15 @@
NSLog
(
@"注册失败%@"
,
error
);
}
-
(
void
)
application
:(
UIApplication
*
)
application
didReceiveRemoteNotification
:(
NSDictionary
*
)
userInfo
fetchCompletionHandler
:(
void
(
^
)(
UIBackgroundFetchResult
))
completionHandler
{
if
([
UIApplication
sharedApplication
].
applicationState
!=
UIApplicationStateActive
)
{
// [self pushNotificationDefaultController];
}
// Required, iOS 7 Support
completionHandler
(
UIBackgroundFetchResultNewData
);
}
-
(
void
)
application
:(
UIApplication
*
)
application
didReceiveRemoteNotification
:(
NSDictionary
*
)
userInfo
{
NSLog
(
@"接收到远程推送通知 ---- %@"
,
userInfo
);
...
...
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMSocketManager.h
View file @
12769036
//
//
...
...
@@ -26,6 +26,8 @@ typedef void(^OffcnIMReceiveConnectStatus)(OffcnIMConnectStatus status,NSString
@interface
OffcnIMSocketManager
:
NSObject
@property
(
nonatomic
,
assign
)
OffcnIMConnectStatus
IMConnectStatus
;
@property
(
nonatomic
,
copy
)
OffcnIMConnectReceiveMessage
connectReceiveMessage
;
@property
(
nonatomic
,
copy
)
OffcnIMReceiveConnectStatus
connectStatus
;
...
...
OffcnIMSDKiOS/ExposedInterface-(外放接口)/OffcnIMSocketManager.m
View file @
12769036
//
//
...
...
@@ -104,12 +104,16 @@ static OffcnIMSocketManager *socketManager;
if
(
self
.
connectStatus
)
{
NSString
*
message
=
[
NSString
stringWithUTF8String
:
context
];
if
(
code
==
0
)
{
self
.
IMConnectStatus
=
OffcnIMConnectStatusSuccess
;
self
.
connectStatus
(
OffcnIMConnectStatusSuccess
,
message
);
}
else
if
(
code
==
1
){
self
.
IMConnectStatus
=
OffcnIMConnectStatusFail
;
self
.
connectStatus
(
OffcnIMConnectStatusFail
,
message
);
}
else
if
(
code
==
2
){
self
.
IMConnectStatus
=
OffcnIMConnectStatusBreak
;
self
.
connectStatus
(
OffcnIMConnectStatusBreak
,
message
);
}
else
if
(
code
==
3
){
self
.
IMConnectStatus
=
OffcnIMConnectStatusDisConnectOK
;
self
.
connectStatus
(
OffcnIMConnectStatusDisConnectOK
,
message
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment