cordova-plugin-iosrtc not work with sip.js 0.11 on movile ionic js webrtc app - ionic-framework

I am developing a webrtc call/videocall app bases on Ionic/AngularJS technologies. The app works with sip.js for call actions over PBX server. For IOS integration with WebRtc, app works with cordova-plugin-iosrtc. When I try connect with PBX to call or received call, app throws errors on two possible use mode of cordova-plugin-iosrtc with sip.js
A) When I try to use cordova-plugin-iosrtc working on peer connection iOS plugin mode ....
telephoneService.js (Angular JS)
var pc = new cordova.plugins.iosrtc.RTCPeerConnection({
iceServers: []
});
cordova.plugins.iosrtc.getUserMedia(
// constraints
{ audio: true, video: true },
// success callback
function (stream) {
console.log('got local MediaStream: ', stream);
pc.addStream(stream);
},
// failure callback
function (error) {
console.error('getUserMedia failed: ', error);
}
);
var sessionDescriptionHandlerOptions = {
constraints: {
audio: audioId,
video: videoId
},
media: {
local: {
audio: document.getElementById('localAudio')
},
remote: {
audio: document.getElementById('remoteAudio')
}
},
extraHeaders: extraHeaders
}
}
userAgent.invite('sipusertocall', sessionDescriptionHandlerOptions);
receive the next error:
undefined is not a object evaluating 'environment.navigator.mediaDevices.getUserMedia' (sip.js lib)
B)
cordova.plugins.iosrtc.registerGlobals(); use iosrtc plugin with webrtc native api (navigator.mediaDevice.getUserMedia(), ....)
navigator.mediaDevices.getUserMedia(
function (stream) {
console.log('got local MediaStream: ', stream);
window.stream = stream;
},
// failure callback
function (error) {
console.error('getUserMedia failed: ', error);
}
)
var sessionDescriptionHandlerOptions = {
constraints: {
audio: audioId,
video: videoId
},
media: {
local: {
audio: document.getElementById('localAudio')
},
remote: {
audio: document.getElementById('remoteAudio')
}
},
extraHeaders: extraHeaders
}
userAgent.invite('sipusertocall', sessionDescriptionHandlerOptions);
App receive from sip.js next error from PBX: Failed:WebRTC Error
Client show next error at same time:
setLocalDescription() must be called with a RTCSessionDescription instance as first argument

So the newer SIP.js is actually passing in an instance of RTCSessionDescriptionInit which although has a similar structure: { sdp: ..., type: ... } to an RTCSessionDescription init is not accepted by the cordova iosrtc implementation.
I have created a fix for this in the form of a custom SDH for SIP.js (as I encountered the exact same issue). My custom SDH converts the object to a new RTCSessionDescription(...) just before it gets passed in to getLocationDescription and setRemoteDescription.
Link to SDH plugin:
https://github.com/iotum/cordova-ios-session-description-handler
Hope this helps!
Wes

Related

Sending voip push notification from one signal triggered firebase cloud functions

I`m trying to send Voip push notification from one signal triggered by firebase cloud functions. So far it being able to send normal message push notifications from one signal to IOS devices using firebase cloud functions with below code.
var sendNotification = function(data) {
var headers = {
"Content-Type": "application/json; charset=utf-8"
};
var options = {
host: "onesignal.com",
port: 443,
path: "/api/v1/notifications",
method: "POST",
headers: headers
};
var https = require('https');
var req = https.request(options, function(res) {
res.on('data', function(data) {
console.log("Response:");
console.log(JSON.parse(data));
});
});
req.on('error', function(e) {
console.log("ERROR:");
console.log(e);
});
req.write(JSON.stringify(data));
req.end();
};
var message = {
app_id: "*********************",
contents: {"en": "English Message"},
include_player_ids: ["******************7b0bdc38"]
};
sendNotification(message);
Does anyone know how to send Voip push notifications from one signal using firebase cloud functions??
(If the above code is required to change some part of it, it would be very thankful telling me where it is.)
As per one signal documentation (https://documentation.onesignal.com/docs/voip-notifications) you are missing the DEVICE_VOIP_TOKEN that you should have received from the iOS application.
Please try adding that and let me know, think of adding the exact error message if any.

Not able to register device with MFP8.0

We are developing ionic app with mfp8.0. We are using the following code to connect with mfp server,
var Messages = {
// Add here your messages for the default language.
// Generate a similar file with a language suffix containing the translated messages.
// key1 : message1,
};
var wlInitOptions = {
// Options to initialize with the WL.Client object.
// For initialization options please refer to IBM MobileFirst Platform Foundation Knowledge Center.
onSuccess:function(){alert('success')},
onFailure:function(){alert('fail')}
};
function wlCommonInit() {
app.init();
}
var app = {
//initialize app
"init": function init() {
app.testServerConnection();
},
//test server connection
"testServerConnection": function testServerConnection() {
WL.App.getServerUrl(function (url) {
});
WLAuthorizationManager.obtainAccessToken()
.then(
function (accessToken) {
alert('accessToken '+JSON.stringify(accessToken));
isPushSupported();
},
function (error) {
alert('Error '+error);
}
);
},
}
function isPushSupported() {
MFPPush.isPushSupported(
function(successResponse) {
alert("Push Supported: " + successResponse);
registerDevice();
}, function(failureResponse) {
alert("Failed to get push support status");
}
);
}
function registerDevice() {
WLAuthorizationManager.obtainAccessToken("push.mobileclient").then(
MFPPush.registerDevice(
{"phoneNumber":""}, // workaround due to a defect in the current release of the product. An empty "phoneNumber" property must be passed at this time.
function(successResponse) {
alert("Successfully registered");
},
function(failureResponse) {
alert("Failed to register");
alert("Failed to register device:" + JSON.stringify(failureResponse));
}
)
);
}
We can able to connect with mfp server. But, We unable register device for push notifcations. We are getting the following error,
"com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushException:Response:Status=404, Text:Error 404: SRVE0295E: Error reported: 404\r\n, Error Message : Not Found"
(or)
"com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushException:Response:Status=500,Text:{\"errorCode\":\"UNEXPECTED_ERROR\",\"errorMsg\":\"Unexpected Error Encountered\"}, Error Message : Unexpected Error Encountered"
Actually, We are getting this error recently. Before that the same code was working fine for us.
Anyone help will be Appreciated!!!
Change the function of Register Device accordingly.
Please go through the link:
https://github.com/MobileFirst-Platform-Developer-Center/PushNotificationsCordova/blob/release80/www/js/index.js
function registerDevice() {
WLAuthorizationManager.obtainAccessToken("push.mobileclient").then(
MFPPush.registerDevice(
null,
function(successResponse) {
alert("Successfully registered");
},
function(failureResponse) {
alert("Failed to register");
alert("Failed to register device:" + JSON.stringify(failureResponse));
}
)
);
}
Your code snippets do not show how did you try to register your application to the push service...
Did you follow the instructions of the push tutorial and looked at the sample push applications before opening a question?
See the tutorials and samples, here: https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/notifications/handling-push-notifications/

Handling Facebook/Google login with ngCordovaOauth in Ionic + Firebase

I'm trying to implement Firebase authentication with angularfire signInWithCredential method for my Ionic app. As I'm using Firebase 3.x SDK, the methods signInWithRedirect and signInWithPopup are not yet supported on mobile devices. Thus I'm using the plugin ngCordovaOauth.
var ref = firebase.database().ref().child("users");
$scope.users = $firebaseArray(ref);
$cordovaOauth.facebook("//removed_client_id", [ "public_profile", "email"]).then(function(result) {
var credentials = firebase.auth.FacebookAuthProvider.credential(result.access_token);
$scope.authObj.$signInWithCredential(credentials).then(function(authData) {
var existUser = $scope.users.$getRecord(authData.uid);
if(existUser == null){
$scope.user = {
uid: authData.uid,
displayName: authData.displayName,
avatar: authData.photoURL,
email: authData.email,
contact: "0000000000",
provider: "facebook"
}
firebase.database().ref("users/" + authData.uid).set($scope.user);
}
$rootScope.result = authData;
$state.go("menu.home");
}, function(error) {
console.error("ERROR: " + error);
});
}, function(error) {
console.log("ERROR: " + error);
});
The problem that I'm facing is I have no idea what the structure of 'authdata' is as I couldn't find any documentation for the same. With sigInWithPopup, firebase returns 'result' object; contents of which can be accessed like 'result.user.uid', 'result.user.displayName' or 'result.user.email'. How can I achieve the same here as I'm trying to store the user profile when he logs in for the first time? Any help? I'm testing on android device. Thank you!
signInWithCredential returns a promise that resolves with a firebase.User same as signInWithEmailAndPassword and all other sign in apis.
Check the docs for more info on firebase.User:
https://firebase.google.com/docs/reference/js/firebase.User

Backend service for ionic push

I have implemented ionic push notifications using pushwoosh. But there I use the dashboard which has provided by pushwoosh to send push notifications. I wanted to send push notifications using a back end which has created by my self. How do I do that?
i am working on ionic-framework and also using push notification to sent notification via REST API using node-gcm its working fine.
sample code
(function() {
function execute(rqst, q, fwk) {
var gcm = require('node-gcm');
var message = new gcm.Message();
message.timeToLive = 3000;
message.addData({
title: 'Push Notification Sample',
body: 'Abnormal data access',
icon: 'ic_launcher',
message: '"\u270C Peace, Love \u2764 and PhoneGap \u2706!'
});
message.addNotification({
title: 'Push Notification Sample',
body: 'Abnormal data access',
icon: 'ic_launcher',
message: 'hey , how are you?'
});
/* message.addData('message', "\u270C Peace, Love \u2764 and PhoneGap \u2706!");
message.addData('title', 'Push Notification Sample');
message.addData('msgcnt', '3');*/
// Duration in seconds to hold in GCM and retry before timing out. Default 4 weeks (2,419,200 seconds) if not specified.
// Set up the sender with you API key
var sender = new gcm.Sender('xxxxxxxxxxxxxxxxx-hK5wE');
// Add the registration IDs of the devices you want to send to
var registrationIds = [];
registrationIds.push('APA91bEWB6-xcrfrfrffr-LqyMohLP4T-XuydQgt44Q6Acw5kmVDWvAaOsm1CriASm02SyBceZ2NBWF4FIES7grcPeY5v4fLQme2UqhRteeWRdD_Ma25QMGESOGAyw_Uhgg_EjkTl-');
// Send the message
// ... trying only once sendNoRetry
sender.send(message, {
registrationIds: registrationIds
}, function(err, result) {
if (err) {
console.error(err);
q.resolve({
status: 200,
data: {
data: err,
code: 1
}
});
} else {
console.log(result);
q.resolve({
status: 200,
data: result
});
}
});
}
return exports.execute = execute;
})();

Video steaming recived but not playing in WebRTC

I am trying to create a audio broadcasting app using WebRTC. To make it compatible with IE I am using Teamsys plugin from Attlasian.
In most of the demos available on internet I have seen two audio/video controls on a single page. But I am trying it with two page application. one for sender and another for reciever.
I am sending my stream description using XHR to a database where it is received by the another user and used as local description for the peer connection on receiver end.
Here is the code :
Sender
function gotStream(stream) {
console.log('Received local stream');
// Call the polyfill wrapper to attach the media stream to this element.
localstream = stream;
audio1 = attachMediaStream(audio1, stream);
pc1.addStream(localstream);
console.log('Adding Local Stream to peer connection');
pc1.createOffer(gotDescription1, onCreateSessionDescriptionError);
}
function gotDescription1(desc) {
pc1.setLocalDescription(desc);
console.log('Offer from pc1 \n' + desc);
console.log('Offer from pc1 \n' + desc.sdp);
$.ajax({
type: "POST",
url: '../../home/saveaddress',
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ SDP: desc }),
dataType: "json",
success: function (result) {
if (result) {
console.log('SDP Saved');
}
});
}
function iceCallback2(event) {
if (event.candidate) {
pc1.addIceCandidate(event.candidate,
onAddIceCandidateSuccess, onAddIceCandidateError);
console.log('Remote ICE candidate: \n ' + event.candidate.candidate);
}
}
At Receiver End
var pcConstraints = {
'optional': []
};
pc2 = new RTCPeerConnection(servers, pcConstraints);
console.log('Created remote peer connection object pc2');
pc2.onicecandidate = iceCallback1;
pc2.onaddstream = gotRemoteStream;
$.ajax({
type: "GET",
url: '../../home/getsavedaddress',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
if (result) {
gotDescription1(result);
}
},
error: function () {
}
});
function gotDescription1(desc) {
console.log('Offer from pc1 \n' + desc.sdp);
console.log('Offer from pc1 \n' + pc2);
pc2.setRemoteDescription(new RTCSessionDescription(desc));
pc2.createAnswer(gotDescription2, onCreateSessionDescriptionError,
sdpConstraints);
}
Using this I get the SDP from server , vedio tag has a source now. but video is not playing not showing anything.a an y clues..
also I am using asp.net for site , do I need to use node js in this project.
Thanks
Your question is lacking information, but I will give my opinion on it.
Are you supporting Trickle ICE? It seems you may be sending the SDP too fast!
When you do a
pc1.setLocalDescription(desc);
The ICE Candidates start being gathered based on the TURN and STUN server configured in your code here (servers parameter):
pc2 = new RTCPeerConnection(servers, pcConstraints);
That said, they are not yet included in your SDP. It can take a few milliseconds before the media ports are set in the localDescription Object. Your first error is that you are sending the "desc" Object from gotDescription1 instead of the post setLocalDescription SDP. That SDP doesn't have the proper media ports yet.
In your code, you are sending the SDP right away without waiting. My guess is that the SDP is not yet completed and you are not supporting Trickle. Because of that, even if signalling might look good, you will not see any media flowing.