What I want to do
I want to subscribe to push notifications notifying me when I make changes to items in Podio.
What I have done to achieve this
I am using the Podio JS library and have read the documentation and gone through the detailed example. I have in accordance with the instructions:
podio.request
call (receiving responseBody
with push
property)The next step in my code is as follows:
var subscribe = getItem.then (function (responseBody){
return podio.push(responseBody.push).subscribe(callback);
});
var notification = subscribe.then (function () { // never gets here!
console.log ('subscribed');
});
What is not working
The code never gets to the notification
part and consequently does not execute console.log ('subscribed')
. The callback I pass to podio.push(responseBody.push).subscribe(callback)
never gets invoked even though I make changes to the relevant item in my Podio account.
When I run console.log(subscribe)
at an interval of 1000 ms the output is and stays:
lib$es6$promise$promise$$Promise {
_id: 2,
_state: undefined,
_result: undefined,
_subscribers:
[ lib$es6$promise$promise$$Promise {
_id: 3,
_state: undefined,
_result: undefined,
_subscribers: [] },
[Function],
undefined ],
_onerror: null }
What my question is
I would very much appreciate help identifying why the push service is not working even though I - as I see it - as done exactly as instructed by the documentation.
Thank you in advance!
答案 0 :(得分:0)
推送服务的订阅实际上在#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h> //mkdir
#include <stdio.h> //printf
#include <errno.h> //error number
#include <unistd.h> //access
#include <string.h> //strcat
#include <ctype.h> //isspace
#include <stdlib.h>//malloc
int addRecord(char* name, char* addr, char* phon);
void trimspaces(char* string,char**ptr);
int addRecord(char* name, char* addr, char* phon){
printf("\n- starting records addReord function -\n");
int success = 0;
char* namt = "";
trimspaces(name,&namt);
char* addt = "";
trimspaces(addr,&addt);
char* phot = "";
trimspaces(phon,&phot);
//this prints "trimmed words: , , "
printf("\n TRIMMED words: %s, %s, %s",namt,addt,phot);
printf("\n- leaving records addrecord function -\n");
return success;
}
void trimspaces(char* string, char** ptr){
printf("\n- entered trimspaces function -");
//PROBLEMS WITH 0 SIZE OR BLANK INPUT
char *str= string;
int slen = strlen(str); //string length
int ctfor = 0; //counter forward
int ctbak = 0; //counter back
while(isspace((unsigned char)*str)){ str++; ctfor++; }; //count to start of word
while(*str){str++;}; //go to end
//unsigned char
do{ str--; ctbak++; }while(isspace((unsigned char)*str)); //count from end to end of word
int cbako = (slen - ctbak) + 1; //counter back reversed
int wlen = cbako - ctfor; //get word length
printf("\nstr_len:%d,counter_fore:%d,counter_bak:%d,cbakreversed:%d,wlen:%d",slen,ctfor,ctbak,cbako,wlen);
while(*str){ str--; }
str++;
while(isspace((unsigned char)*str)){
str++;
}
char newStr[wlen+1]; //char pointer gives segmentation fault
memcpy(newStr,str,wlen); //not null terminated
newStr[wlen] = '\0';
printf("\n--%s--",newStr);
//PASS POINTER TO POINTER for malloc to work / malloc inside another function
*ptr = malloc(sizeof(newStr)+1); //memory
strcat(*ptr,newStr);
printf("\nPTR is : %s",*ptr);
printf("\n- leaving trimspaces function -");
}
int main(){
addRecord(" ertsfs "," 120,Dans st "," 111 000 222");
}
中被破坏,并且已在1.6.0版本中修复。 (如果对代码更改感兴趣,请参阅this PR)
请升级到podio-js
的最新版本,您应该好好去。
一个小例子(使用ES6表示法)
podio-js