ios - XMPP background connection in iPhone -
i using silent push notification in xmpp chat application. using want connect xmpp server when app not running or not in background mode. receiving silent push notification , enable following flag of xmppstream background connection.
xmppstream.enablebackgroundingonsocket = yes;
but socketdidconnect method not being still called when app not running , can't able connect xmpp server.
the purpose of send message received status xmpp server. guide me this.
i don't want use voip this. please provide me alternate solution this.
follow below steps. possible using voip , pushkit framework.
- enable voip service certificate app. check below image.
- enable voice on ip app. check below image.
now add pushkit.framework
in appdelegate.h file import pushkit framework , add delegate pkpushregistrydelegate
appdelegate.m file following.
a) in didfinishlaunchingwithoptions method add below code.
pkpushregistry *voipregistry = [[pkpushregistry alloc] initwithqueue:dispatch_get_main_queue()]; voipregistry.delegate = self; voipregistry.desiredpushtypes = [nsset setwithobject:pkpushtypevoip];
b) add delegate methods of pkpushregistrydelegate
- (void)pushregistry:(pkpushregistry *)registry didinvalidatepushtokenfortype:(nsstring *)type { nslog(@"voip - did invalidate push token type - %@", type); } - (void)pushregistry:(pkpushregistry *)registry didreceiveincomingpushwithpayload:(pkpushpayload *)payload fortype:(nsstring *)type { nslog(@"voip - got push payload: %@ , type: %@", payload.dictionarypayload, type); nsdictionary *dictaps = [payload.dictionarypayload valueforkey:@"aps"]; if ([dictaps valueforkey:@"content-available"] != nil) { nslog(@"silent voip"); //fetch payload info , create local notification , fire local notification. uilocalnotification *voipnotification = [[uilocalnotification alloc] init]; voipnotification.alerttitle = @"silent voip"; voipnotification.alertbody = [dictaps valueforkey:@"alert"]; voipnotification.soundname = uilocalnotificationdefaultsoundname; [[uiapplication sharedapplication] presentlocalnotificationnow:voipnotification]; //call xmpp connection method here. if (xmppstream == nil) { [self setupstream]; } if ([xmppstream isdisconnected]) { [self connect]; } } } - (void)pushregistry:(pkpushregistry *)registry didupdatepushcredentials:(pkpushcredentials *)credentials fortype:(nsstring *)type { nslog(@"voip - device token: %@", credentials.token); nsstring *newtoken = credentials.token.description; newtoken = [newtoken stringbytrimmingcharactersinset:[nscharacterset charactersetwithcharactersinstring:@"<>"]]; newtoken = [newtoken stringbyreplacingoccurrencesofstring:@" " withstring:@""]; nslog(@"voip token is: %@", newtoken); [obj_datamodel setvoiptoken:newtoken]; //store token in somewhere further use. }
i passing following payload purpose server.
{"aps":{"alert":"testing...","badge":1,"sound":"default","content-available":1}}
i hope helpful you. if have query ask me.
wiki
Comments
Post a Comment