Commit d2eab6a0 by zhangyunjie

推送本地

parent 6426bfa1
...@@ -26,19 +26,6 @@ ...@@ -26,19 +26,6 @@
self.window.backgroundColor = [UIColor whiteColor]; self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible]; [self.window makeKeyAndVisible];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
UILocalNotification *backgroudMsg = [[UILocalNotification alloc] init];
if (backgroudMsg) {
backgroudMsg.timeZone = [NSTimeZone defaultTimeZone];
backgroudMsg.alertBody = @"VoIP来电";
backgroudMsg.alertAction = @"查看";
NSDictionary *infoDic = [NSDictionary dictionaryWithObject:@"name" forKey:@"key"];
backgroudMsg.userInfo = infoDic;
[[UIApplication sharedApplication] presentLocalNotificationNow:backgroudMsg];
//[self cerateAVAudioPlayer];
}
});
//中公直播使用测试环境设置为YES,正式环境设置为NO或者去掉这个配置 //中公直播使用测试环境设置为YES,正式环境设置为NO或者去掉这个配置
NSNumber *changeEnvironment = [[NSUserDefaults standardUserDefaults] valueForKey:kOffcnIMSDKiOS_changeEnvironment]; NSNumber *changeEnvironment = [[NSUserDefaults standardUserDefaults] valueForKey:kOffcnIMSDKiOS_changeEnvironment];
...@@ -111,14 +98,14 @@ ...@@ -111,14 +98,14 @@
NSLog(@"-----deviceToken ---- ---- %@ devDesc ---%@", deviceToken,deviceToken.description); NSLog(@"-----deviceToken ---- ---- %@ devDesc ---%@", deviceToken,deviceToken.description);
//tokenStr 得到可用的token。 //tokenStr 得到可用的token。
NSString *tokenStr = [NSString stringWithFormat:@"%@",deviceToken]; // NSString *tokenStr = [NSString stringWithFormat:@"%@",deviceToken];
tokenStr = [tokenStr stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];//将其中的<>去掉 // tokenStr = [tokenStr stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];//将其中的<>去掉
tokenStr = [tokenStr stringByReplacingOccurrencesOfString:@" " withString:@""];//将其中的空格去掉 // tokenStr = [tokenStr stringByReplacingOccurrencesOfString:@" " withString:@""];//将其中的空格去掉
NSString *str = [self hexStringForData:deviceToken]; NSString *str = [self hexStringForData:deviceToken];
NSLog(@"token--- %@",str); NSLog(@"token--- %@",str);
//注册成功,返回token //注册成功,返回token
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"APNS返回的Token:" message:tokenStr delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"APNS返回的Token:" message:str delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[alert show]; [alert show];
// applicationIconBadgeNumber // applicationIconBadgeNumber
...@@ -151,7 +138,7 @@ ...@@ -151,7 +138,7 @@
} }
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
NSLog(@"接收到推送通知 ---- %@", userInfo); NSLog(@"接收到远程推送通知 ---- %@", userInfo);
/* /*
...@@ -172,6 +159,7 @@ ...@@ -172,6 +159,7 @@
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:message delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:message delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[alert show]; [alert show];
UILocalNotification *backgroudMsg = [[UILocalNotification alloc] init]; UILocalNotification *backgroudMsg = [[UILocalNotification alloc] init];
if (backgroudMsg) { if (backgroudMsg) {
backgroudMsg.timeZone = [NSTimeZone defaultTimeZone]; backgroudMsg.timeZone = [NSTimeZone defaultTimeZone];
...@@ -183,6 +171,9 @@ ...@@ -183,6 +171,9 @@
//[self cerateAVAudioPlayer]; //[self cerateAVAudioPlayer];
} }
} }
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{
NSLog(@"接收到本地推送通知 ---- %@", notification.userInfo);
}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{ - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{
......
...@@ -93,6 +93,14 @@ ...@@ -93,6 +93,14 @@
<action selector="connectAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="PbK-7D-LjH"/> <action selector="connectAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="PbK-7D-LjH"/>
</connections> </connections>
</button> </button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Vmx-zP-DRW">
<rect key="frame" x="87" y="95" width="92" height="30"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="发送本地通知"/>
<connections>
<action selector="sendLocalNotiAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="jbM-Ii-Hmr"/>
</connections>
</button>
</subviews> </subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints> <constraints>
...@@ -117,7 +125,10 @@ ...@@ -117,7 +125,10 @@
<constraint firstItem="HDM-va-7kG" firstAttribute="top" secondItem="a21-3W-10n" secondAttribute="bottom" id="lS8-hA-rmu"/> <constraint firstItem="HDM-va-7kG" firstAttribute="top" secondItem="a21-3W-10n" secondAttribute="bottom" id="lS8-hA-rmu"/>
<constraint firstItem="7fD-Hf-Afy" firstAttribute="leading" secondItem="TnX-iH-azN" secondAttribute="leading" id="lea-oR-ecV"/> <constraint firstItem="7fD-Hf-Afy" firstAttribute="leading" secondItem="TnX-iH-azN" secondAttribute="leading" id="lea-oR-ecV"/>
<constraint firstItem="1dp-RW-FhV" firstAttribute="height" secondItem="TnX-iH-azN" secondAttribute="height" id="pCJ-es-iPl"/> <constraint firstItem="1dp-RW-FhV" firstAttribute="height" secondItem="TnX-iH-azN" secondAttribute="height" id="pCJ-es-iPl"/>
<constraint firstItem="Vmx-zP-DRW" firstAttribute="height" secondItem="dRe-f0-gnl" secondAttribute="height" id="uLF-IL-l61"/>
<constraint firstItem="Vmx-zP-DRW" firstAttribute="leading" secondItem="dRe-f0-gnl" secondAttribute="trailing" constant="10" id="vfp-Yh-YD6"/>
<constraint firstItem="9JE-Lz-Dma" firstAttribute="top" secondItem="1dp-RW-FhV" secondAttribute="bottom" constant="5" id="xMf-AL-l1H"/> <constraint firstItem="9JE-Lz-Dma" firstAttribute="top" secondItem="1dp-RW-FhV" secondAttribute="bottom" constant="5" id="xMf-AL-l1H"/>
<constraint firstItem="Vmx-zP-DRW" firstAttribute="top" secondItem="dRe-f0-gnl" secondAttribute="top" id="zxs-bV-awe"/>
</constraints> </constraints>
</view> </view>
<connections> <connections>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#import "ViewController.h" #import "ViewController.h"
#import "OffcnIMSDKiOS.h" #import "OffcnIMSDKiOS.h"
#import "OffcnNetworkExecutor.h" #import "OffcnNetworkExecutor.h"
//#import "oimcoreAdapter.h" //#import <oimcore/oimcoreAdapter.h>
@interface ViewController ()<UITextFieldDelegate> @interface ViewController ()<UITextFieldDelegate>
...@@ -41,6 +41,9 @@ ...@@ -41,6 +41,9 @@
- (IBAction)connectAction:(UIButton *)sender { - (IBAction)connectAction:(UIButton *)sender {
} }
- (IBAction)sendLocalNotiAction:(UIButton *)sender {
}
- (IBAction)sendMeg:(UIButton *)sender { - (IBAction)sendMeg:(UIButton *)sender {
//发送消息 //发送消息
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment