Messenger extension in not working in webview - webview

After whitelisting my domain, I try to access messenger extension to get the user ID, it failed with error :
Messenger Extensions are not enabled - could be "messenger_extensions"
was not set on a url, the domain was not whitelisted or this is an
outdated version of Messenger client
I tried the messenger on google chrome and firefox same error is appearing. messenger_extensions is set to true and domain is whitelisted; I confirmed.
Why is it bring that message?

Are you trying to access it through a browser? If so that may be why you are having issues.
Try access the url through the messenger app on your phone. This will iFrame in the web page and you will have access to the MessengerExtensions sdk.
Not sure how you are supposed to be able to log within messenger though. I did something like this to test it out
window.extAsyncInit = function() {
// the Messenger Extensions JS SDK is done loading
MessengerExtensions.getUserID(function success(uids) {
// User ID was successfully obtained.
var psid = uids.psid;
console.log("psid", psid)
$('.error').html(psid)
}, function error(err, errorMessage) {
// Error handling code
console.log(err, errorMessage)
$('.error').html(errorMessage)
});
};

You should add image_url to the message. This field isn't required, but if you don't include it, the shared message will only work within a mobile context.
Example:
var messageToShare = {
attachment: {
type: "template",
payload: {
template_type: "generic",
elements: [{
title: "Title",
image_url: "https://image.flaticon.com/teams/slug/freepik.jpg",
subtitle: 'A shared list from Tasks',
default_action: {
type: "web_url",
url: "your_url",
messenger_extensions: true,
webview_height_ratio: "full",
fallback_url: "fallback_url"
},
buttons: [{
type: "web_url",
title: "title",
url: "your_url",
messenger_extensions: true,
webview_height_ratio: 'full',
fallback_url: "fallback_url"
}]
}]
}
}
};
Also, with messenger_extensions: true you'll need to add fallback_url: "<your_fallback_url_here>" to make it work.

Related

Office 365 api draft flag

I have an Office 365 extension that provides its own "Send" button which does some custom processing of the "draft" email and sends it through other means (ie not Office 365 Web). Since the email isn't sent by Outlook it never makes it to the sent folder (which makes sense). I would like to take that draft email and move it to the sent folder and remove the draft flag so it looks like it was sent by Outlook 365 Web.
var getMessageUrl = Office.context.mailbox.restUrl + '/v2.0/me/messages/' + itemId;
var data = JSON.stringify({ 'ToRecipients': [{ 'EmailAddress': { 'Address': 'sheprts#cox.net', 'Name': 'Katie Jordan' } }], 'IsRead': true, 'IsDraft': false });
$.ajax({
url: getMessageUrl,
type: 'PATCH',
dataType: 'json',
headers: { 'Authorization': 'Bearer ' + accessToken, 'Content-Type': 'application/json' },
data: data
})
})
.done(function (item) {
})
.fail(function (error) {
var err = ""
});
The request above works fine except the changing of the draft flag. If this isn't the solution what else can I do? I need to get a draft email into the sent folder as "Not" a draft.
Unfortunately you cannot create non-draft messages using the API.
Change your "other means" and set the "SaveInSentFolder" flag; or change to SMTP for your "other means".

iOS Apple Review Team can't connect to my App using the credentials i gave them

I've sent my app for review in the Apple Store Connect, it contains a signing form in order to access its content. I’ve added a demo account credentials in order for them to review it.
Apple Team tried to connect to my app twice using 2 different credentials, they received a custom message that i made, showing that the login/password are wrong, and I’m 100% sure that the password is correct.
Important edit: The application is working correctly on real and virtual devices, and it connect normaly to the server using the form.
The server side is built using Laravel / Passport, and whenever the credentials are wrong: the server response with a 401 error:
{
error:{
error: "invalid_credentials",
message: "The user credentials were incorrect."
},
...
message: "Http failure response for https://mydomain.name/api/oauth/token: 401 Unauthorized",
name: "HttpErrorResponse",
ok: false,
status: 401,
statusText: "Unauthorized",
...
}
N.B: This response shows up on the Google Chome debug console when i try to connect with false credentials, using the Ionic Serve command
I’ve built my app using Ionic 3, and here is how i interpret the server response to show the error message:
this.userProvider.loginUser(this.email.toLowerCase().trim(),this.password).subscribe((response) => {
this.storage.set('access_token',response['access_token']);
this.storage.set('email',this.email.toLowerCase().trim());
}, (response) => {
if(response.status == 401) {
let alert = this.alertCtrl.create({
title: 'Invalid credentials',
message: 'Please check your credentials.',
buttons: ['Fermer']
});
alert.present();
}
}, () => {
....
});
export class UserProvider {
private apiUrl = 'https://mydomain.name/api';
constructor(private httpClient: HttpClient) {
}
public loginUser(email: string, password: string) {
return this.httpClient.post(this.apiUrl + '/oauth/token', {
grant_type: 'password',
client_secret: '******************************************',
client_id: *,
username: email,
password: password
}).map(response => {
return response;
});
}
}
Is it possible that the 401 response received by the Apple Team has another interpretation?
How can i solve this issue ?

youtube api v3 CORS support in sencha touch 2

Using Sencha Touch, How do we query youtube v3 search api?
Below is the sample url which works fine when issued from a browser directly (NOTE: Key is required) :
"https://www.googleapis.com/youtube/v3/search?part=snippet&order=date&type=video&channelId=UC3djj8jS0370cu_ghKs_Ong&key=MY_KEY"
However the same url fails when loaded using sencha touch Store ajax proxy.
It seems that OPTIONS call is made against this URL and GET was aborted.
What is needed in Sencha touch store for working with youtube V3 google apis? I did not find jsonp support for youtube V3 api.
I have used this api like this,
proxy: {
type: 'ajax',
url: 'https://www.googleapis.com/youtube/v3/search',
useDefaultXhrHeader: false,
extraParams: {
part: 'snippet',
q: 'ambarsariya',
regionCode: 'IN',
maxResults: 30,
key: 'your_key'
},
reader: {
type: 'json',
rootProperty: 'items'
}
}
One more thing you have to do and thats is you have set a idProperty in the model of this store. Inside config of the model used I have used
idProperty: 'videoId',// its better if this name is not same as any fields name
fields: [{
name: 'snippet'
}, {
name: 'thumbnail',
mapping: 'snippet.thumbnails.default.url'
}, {
name: 'title',
mapping: 'snippet.title'
}]
Hope this solves your problem.
It works well for me.
STORE:-
Ext.define('MyApp.store.videos', {
extend: 'Ext.data.Store',
model: 'MyApp.model.Video',
config: {
autoLoad: true,
proxy: {
type: 'ajax',
//This is required to enable cross-domain request
useDefaultXhrHeader: false,
url: 'https://www.googleapis.com/youtube/v3/search',
extraParams: {
part: 'snippet',
q: "Enrique", //Query string
regionCode: 'IN',
maxResults: 30,
key: 'AIzaSyD6FvoLaIFqyQGoEY4oV7TEWGAJSlDd1-8'
}
}
}
});
This is the model used by the above store.
MyApp.model.Video:-
Ext.define('MyApp.model.Video', {
extend: 'Ext.data.Model',
requires: [],
config: {
idProperty: 'videoId',
fields: [{
name: 'id'
}, {
name: 'videoId',
mapping: 'id.videoId'
}]
}
});
It also works well for jsonp proxy also,
just change type: jsonp inside proxy and remove useDefaultXhrHeader config.

Sencha Touch 2: Trying to create a login form

I am a 100% newb to Sencha and am trying to take a stab at re-factoring my company's mobile app.
Here is my app.js:
Ext.application({
name: 'RecruitTalkTouch',
views: ['Login'],
launch: function () {
Ext.Viewport.add([
{ xtype: 'loginview' }
]);
}
});
Login.js View:
Ext.define('RecruitTalkTouch.view.Login', {
extend: 'Ext.Container',
alias: "widget.loginview",
xtype: 'loginForm',
id: 'loginForm',
requires: ['Ext.form.FieldSet', 'Ext.form.Password', 'Ext.Label', 'Ext.Button' ],
config: {
title: 'Login',
items: [
{
xtype: 'label',
html: 'Login failed. Please enter the correct credentials.',
itemId: 'signInFailedLabel',
hidden: true,
hideAnimation: 'fadeOut',
showAnimation: 'fadeIn',
style: 'color:#990000;margin:5px 0px;'
},
{
xtype: 'fieldset',
title: 'Login Example',
items: [
{
xtype: 'textfield',
placeHolder: 'Email',
itemId: 'userNameTextField',
name: 'userNameTextField',
required: true
},
{
xtype: 'passwordfield',
placeHolder: 'Password',
itemId: 'passwordTextField',
name: 'passwordTextField',
required: true
}
]
},
{
xtype: 'button',
itemId: 'logInButton',
ui: 'action',
padding: '10px',
text: 'Log In'
}
]
}
});
Login.js Controller:
Ext.define('RecruitTalkTouch.controller.Login', {
extend: 'Ext.app.Controller',
config: {
refs: {
loginForm: 'loginForm'
},
control: {
'#logInButton': {
tap: 'onSignInCommand'
}
}
},
onSignInCommand: function(){
console.log("HELLO WORLD");
}
});
When I click the submit button, nothing happens. How can I hook up my submit button to listen for events (click, tap, etc) along with submitting the information to a backend API?
In app.js file of your application, add:
controllers: [
'Login'
]
in your application class. And for submitting information, call a Ajax request like this:
Ext.Ajax.request({
url: // api url..,
method: 'POST',
params: {
username: // get user name from form and put here,
password: // get password and ...
},
success: function(response) {
do something...
},
failure: function(err) {do ..}
});
from inside onSignInCommand() function.
You must activate your controller by adding it to the controllers option of your application class.
Then, to submit your data to the backend, you've got several options. You can use a form panel instead of your raw container, and use its submit method. Alternatively, you can use the Ext.Ajax singleton. In this case, you'll have to build the payload yourself. Finally, you can create a model with a configured proxy, and use its save method. This last way is probably the best for long term maintainability... Even if in the case of a simple login form, that may be a little bit overkill.
Can u please refer this sample app to create login form. Its very simple app please go through it.
http://miamicoder.com/2012/adding-a-login-screen-to-a-sencha-touch-application/

How to upload recorded audio (recorder.js-master) through MVC Controller?

I've been working with a great audio recorder which is recorder.js-master.
But I can't make the upload work with MVC Controller.
Here's my javascript function.
function AudioUpload(title, description) {
Recorder.upload({
method: "POST",
url: '#Url.Action("Upload", "Audio")',
audioParam: "Recording",
params: {
"Title": title,
"Description": description
},
success: function (responseText) {
alert(responseText.Success);
},
error: function () {
alert("error");
},
progress: NULL
});
}
Here's my AudioController
public JsonResult Upload(VoicePassage passage)
{
//upload Audio
return Json(new { Success = true });
}
I have a breakpoint in Upload just to know that it's going to my Controller but it doesn't.
Please help.
Here's the reference I follow. http://marc.codewisp.com/2013/05/07/in-browser-audio-recording-recorder-js-asp-net-mvc/?replytocom=12#respond
Regards,
Christian
I'm the author of the original post you linked to.
A few things to try out:
Add a breakpoint to the JavaScript function: if it doesn't hit, something's wrong with your JavaScript.
Check your browser's network activity: In Chrome, under Developer Tools, go to the Network tab and attempt the upload. See if it is hitting the right URL.
Make sure you're using '#Url.Action...' inside a Razor view. It won't work in external JavaScript files.
If you need #Url.Action, you can probably use it in your Razor view, assign it to a temporary global variable and use it in your external JavaScript file.
In your View, add the following before the reference to your external JS:
<script type="text/javascript">
var audioAction = '#Url.Action("Upload", "Audio")';
</script>
In your JavaScript file, change '#Url.Action("Upload", "Audio")' to audioAction, as in:
function AudioUpload(title, description) {
Recorder.upload({
method: "POST",
url: audioAction,
audioParam: "Recording",
params: {
"Title": title,
"Description": description
},
success: function (responseText) {
alert(responseText.Success);
},
error: function () {
alert("error");
},
progress: NULL
});
}

Resources