iOS端通过api的方式发送一个推送,但是极光后台推送历史中没有,客服端也接收不到推送

ios
标签: #<Tag:0x00007fb83feef350>

(Dream) #1

我现在用iOS端发送一个推送,但是极光后台推送历史中没有,并且也接收不到推送,请问怎么回事,谢谢


#2

请提供你推送的消息的msgid(API推送有返回)和你收不到消息的设备的registrationID


(Dream) #3

我现在调用这个接口,但是没有任何返回值,而且推送历史API中也没有任何消息


(Dream) #4
-(void)shopidNotify:(NSMutableDictionary *)dics andSuccess:(void(^)(NSMutableDictionary *autdic))success{
    
    AFHTTPSessionManager *manage=[AFHTTPSessionManager manager];
    manage.responseSerializer=[AFHTTPResponseSerializer serializer];
    
    [manage POST:@"http://101.37.34.116/task/home/images/push_example.php" parameters:dics constructingBodyWithBlock:nil progress:nil success:^(NSURLSessionDataTask *task, NSData *data) {
//        NSMutableDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
//        success(dic);
        NSLog(@"成功传shopid");
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        NSLog(@"error");
        NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
        [dic setObject:@"error" forKey:@"code"];
        success(dic);
    }];
}

这个是我们调用的接口


#5

php 参考SDK的example,打印下response


(Dream) #6
<?php

ini_set("display_errors", "On");
error_reporting(E_ALL | E_STRICT);
require_once("src/JPush.php");

$br = '<br/>';
$app_key = 'efb60329525c23e3add37f70';
$master_secret =

$client = new JPush($app_key, $master_secret);

$shopid=$_POST["shopid"];
$result = $client->push()
    ->setPlatform(array('ios', 'android'))
    ->addAlias("$shopid")
    ->setNotificationAlert('Hi, JPush')
    ->addAndroidNotification('Hi, android notification', 'notification title', 1, array("key1"=>"value1", "key2"=>"value2"))
    ->addIosNotification("您有条新校", 'iOS sound', '+1', true, 'iOS category', array("key1"=>"value1", "key2"=>"value2"))
    ->setMessage("msg content", 'msg title', 'type', array("key1"=>"value1", "key2"=>"value2"))
    ->setOptions(100000, 3600, null, true)
    ->send();

echo 'Result=' . json_encode($result) . $br;

这是我的PHP的接口
就一个参数,shopid
然后调用之后的结果如下:


<br />
<b>Fatal error</b>:  Uncaught exception 'APIRequestException' with message 'Missing parameter' in C:\xampp\htdocs\task\Home\images\src\core\PushPayload.php:577
Stack trace:
#0 C:\xampp\htdocs\task\Home\images\src\core\PushPayload.php(550): PushPayload-&gt;__processResp(Array)
#1 C:\xampp\htdocs\task\Home\images\push_example.php(22): PushPayload-&gt;send()
#2 {main}
  thrown in <b>C:\xampp\htdocs\task\Home\images\src\core\PushPayload.php</b> on line <b>577</b><br />

#7

请保护好自己的私密信息,master_secret不要发出来


(Dream) #8

好的,谢谢,原来是因为接口保存的格式不对,原来保存的是asi格式的,换成uff-8就可以了


(Dream) #9

现在发送推送,极光后台有历史记录了,但是接收不到推送,详细资料如下:
Message ID 993019634
推送平台 ios-product,android
推送结果 已发送
audience {“alias”:[“70”]}
notification {“android”:{“title”:“notification title”,“builder_id”:1,“extras”:{“key2”:“value2”,“key1”:“value1”},“alert”:“Hi, android notification”},“ios”:{“sound”:“iOS sound”,“content-available”:true,“alert”:“您有新的订单”,“extras”:{“key2”:“value2”,“key1”:“value1”},“category”:“iOS category”,“badge”:"+1"},“alert”:“Hi, JPush”}
message {“msg_content”:“msg content”,“extras”:{“key2”:“value2”,“key1”:“value1”},“content_type”:“type”,“title”:“msg title”}
options {“sendno”:100000,“time_to_live”:3600,“apns_production”:true}


#10

在客户端获取一下设备的registrationID给我。
https://docs.jiguang.cn/jpush/client/iOS/ios_api/#registrationid
https://docs.jiguang.cn/jpush/client/Android/android_api/#registrationid-api


(Dream) #11

101d85590976adf0bb5


#12

1、你给我的这个registrationID注册时间:2017-05-25 11:16:32
2、刚刚这条消息的推送时间:2017-05-25 11:10:23

3、后面你推送的报错环境不一致,请修改apns_production为false推送开发环境的消息


(Dream) #13

还想要请教一个问题,现在我要推送给客户,但是需要2个参数才能准确定位到客户,如何设置alias?谢谢


#14

API有文档说明的
https://docs.jiguang.cn/jpush/client/iOS/ios_api/#api-ios


(Dream) #15

->addTag([‘tag1’, ‘tag2’]);
->setTagAdd(array(“tag1”,“tag2”))
同时满足2个tag条件,使用第一种还是第二种,这样写的方式对吗?


(Dream) #16

客户端是这样写的:
NSSet *tags=[[NSSet alloc]initWithObjects:@“1”,@“2”,@“3”, nil];
[JPUSHService setTags:tags alias:[userdefault objectForKey:@“class2id”] callbackSelector:@selector(tagsAliasCallback:tags:alias:) object:nil];


#17

代码方面你自己研究下,可以参考客户端的demo 和服务端SDK的example