我正在尝试使用新的推送通知堆栈或将其替换为系统托盘中的android.
我不知道如何执行此操作,因为推送通知正在发送回数据和通知对象,并且据我所知,通知直接发送到系统托盘.如果是这样,我如何阻止通知独立出现.有些用户会收到5-10个通知,而且会继续推升.
编辑:
我尝试了collapse_key,但它仍然没有用相同的密钥替换先前的通知......我在这里做错了吗?
method: 'POST',
uri: 'https://gcm-http.googleapis.com/gcm/send',
headers: {
'Content-Type': 'application/json',
'Authorization': authorize //GOOGLE API KEY
},
body: JSON.stringify({
"registration_ids": [otherUserResult.reg_id],
"collapse_key": "follow",
"data": {
"notifyToUserId": to,
"notifyFromId": from,
"notifyMsg": msg,
"notifyItemPicture": itemPic,
"notifyItemName": itemName,
"notifyFromName": fromName,
"notifyType": type,
"dateNotified": dateNotified
},
"notification": {
"title": fromName,
"body": notifyMsg,
"icon" : "ic_pushnotify"
},
"priority": "high",
"content_available": true
Run Code Online (Sandbox Code Playgroud) notifications android push-notification firebase firebase-notifications
嗨所以我遇到过这个问题,因为在节点js的加密上创建一个随机令牌.
require('crypto').randomBytes(48, function(ex, buf) {
var token = buf.toString('hex');
});
Run Code Online (Sandbox Code Playgroud)
我想弄清楚如何将它添加到我的路线文件中?我已经在我的mongoose模式中将一个标记字段设置为一个类型字符串.
exports.forgotPasswordPost = function(req, res, next) {
console.log("Forgot Password Post");
if(req.body.email === '') {
console.log('err');
} else {
crypto.randomBytes(48, function(ex, buf) {
var userToken = buf.toString('hex');
console.log(userToken);
User.findOne({email: (req.body.email)}, function(err, usr) {
if(err || !usr) {
console.log('err');
}
console.log(usr);
usr.token = new User({token: userToken});
usr.save(function(err, usr){
res.redirect('login', {title: 'Weblio', message: 'Your token was sent by email. Please enter it on the form below.'});
});
});
});
}
};
Run Code Online (Sandbox Code Playgroud)
猫鼬文件:
var …Run Code Online (Sandbox Code Playgroud) 这是我的代码,用于循环访问用户的结果,然后我尝试循环访问用户搜索所发出的好友请求数组。但是,我不断收到 TypeError:无法读取未定义的属性 '$elemMatch。我正在使用 mongoose 和 Node.Js,这个 searchPost 位于路由文件夹中。
exports.searchPost = function(req, res, err) {
User.find({$or:[
{firstName: req.body.firstName},
{lastName: req.body.lastName},
{email: req.body.email},
{phone: req.body.phone}]
}, function(err, users, userAdd) {
if(err) {
return res.render('searchError', {title: 'Weblio'});
} else {
if(req.body.firstName=== '' && req.body.lastName==='' && req.body.email==='' && req.body.phone=== '') {
return res.render('searchError', {title: 'Weblio'});
} else {
for(x in users) {
User.findById(req.signedCookies.userid,
{friendRequest: x.id}
if(x.id === true ) {
console.log('addman1');
return userAdd = false;
} else {
console.log('addman2');
return userAdd = true;
} …Run Code Online (Sandbox Code Playgroud) 嘿所以我试图接受一个上传的文件,但每次我调用req.files它都被认为是未定义的...不确定我做错了什么...
这是我的app.js文件:
var express = require('express')
, user = require('./routes/user')
, http = require('http')
, path = require('path')
, mongoose = require('mongoose')
, mongoConnect = mongoose.connect('mongodb://localhost/clothing')
, app = express();
// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser({uploadDir: './public/img'}));
app.use(express.multipart());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
app.get('/user', user.user);
app.post('/user', user.userPost);
Run Code Online (Sandbox Code Playgroud)
然后在我的路线文件中我只是打电话
req.files
Run Code Online (Sandbox Code Playgroud)
在客户端,我打电话给:
form(action="/user", method="post")
label name:
input(type="text", name="name")
label pic:
input(type="file", name="picture", enctype="multipart/form-data")
input(type="submit", value="Add New Clothes Item")
Run Code Online (Sandbox Code Playgroud) 所以我试图从我的模型中获取验证以实际禁用保存按钮,但重新验证何时包含新输入.任何人都知道尝试这个的最好方法.谢谢!我的方法遇到的问题是,一旦它被禁用,它就不会返回状态.
这是main.js文件
(function () {
window.App = {
Models: {},
Collections: {},
Views: {},
Templates: {},
Router: {}
};
// MODEL
App.Models.User = Backbone.Model.extend({
defaults: {
firstName: 'first',
lastName: 'last',
email: 'Email',
phone: '222',
birthday: '07/22/1980'
},
validate: function (attrs) {
if (!attrs.firstName) {
return 'You must enter a real first name.';
}
if (!attrs.lastName) {
return 'You must enter a real last name.';
}
if (attrs.email.length < 5) {
return 'You must enter a real email.';
}
if (attrs.phone.toString().length …Run Code Online (Sandbox Code Playgroud) 我有一个使用此代码的POST:
exports.addContactPost = function(req, res, err) {
User.findByIdAndUpdate(req.signedCookies.userid, {
$push: {friendRequest: req.body.friendRequest}
}, function(err) {
if(err) {
console.log(err);
return console.log('error');
} else {
console.log('postsuccess');
res.json({response: true});
}
});
};
Run Code Online (Sandbox Code Playgroud)
如何获取$ push:代码行并声明如果id已经存在于不推送的friendRequest数组中.我试图使用$ exists:但我无法让它工作.
所以我在过去的一天看了几百个问题,阅读了所有内容,这就是我收集的内容......
一个人说添加这个:
homeRecyclerView.setHasFixedSize(true);
Run Code Online (Sandbox Code Playgroud)
我试过什么都没做,因为向下或向上滚动的问题是否滞后?二者皆是.
这是一个drawable,我正在使用Picasso(drawable因为我想在进行服务器调用之前测试视图)所以有人说可能缓存系统正在影响它,删除Picasso并且默认情况下imageview有图像但仍然滞后.. .
以下是家庭活动中的声明:
homeRecyclerView = (RecyclerView) findViewById(R.id.home_recycler_view);
homeRecyclerView.setHasFixedSize(true);
homeAdapter = new HomeAdapter(this, homeList);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
homeRecyclerView.setLayoutManager(mLayoutManager);
homeRecyclerView.setItemAnimator(new DefaultItemAnimator());
homeRecyclerView.setAdapter(homeAdapter);
public interface ClickListener {
void onClick(View view, int position);
void onLongClick(View view, int position);
}
public static class RecyclerTouchListener implements RecyclerView.OnItemTouchListener {
private GestureDetector gestureDetector;
private MainHome.ClickListener clickListener;
public RecyclerTouchListener(Context context, final RecyclerView recyclerView, final MainHome.ClickListener clickListener) {
this.clickListener = clickListener;
gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapUp(MotionEvent e) { …Run Code Online (Sandbox Code Playgroud) 嘿所以如何查询属于用户的朋友集合的特定数组项.
这是查询:
Friend.find({userId: req.signedCookies.userid, 'friendStatus.labels': req.body.searchLabels
}, function(err, users) {
Run Code Online (Sandbox Code Playgroud)
这个细分是userId是一种查找已签名的用户文档的方法然后我想只访问嵌套在friendStatus数组内的对象的labels数组中的标签...
这是一个文档的示例:
> db.friends.find({'firstName': "test3"}).pretty()
{
"__v" : 0,
"_id" : ObjectId("520a4944c24d995410000008"),
"accepted_notifications" : true,
"added_notifications" : true,
"firstName" : "test3",
"firstNameTrue" : "test3",
"friendStatus" : [
{
"favorites" : 1,
"fuId" : ObjectId("520a4905c24d995410000001"),
"labels" : [
"new",
"old"
],
"notes" : "He likes me",
"status" : 3
},
{
"fuId" : ObjectId("520a4925c24d995410000004"),
"labels" : [ ],
"notes" : "sadwa",
"status" : 3
}
],
"lastName" : "test3s",
"lastNameTrue" : …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用此代码在我的故事板中实例化一个新的视图控制器,但它什么都不做,并保留在旧的故事板上.
这是代码:
(void)menuSelect:(id)sender {
UIButton *button = (UIButton*) sender;
switch (button.tag) {
case 0: {
HomeViewController *hc=[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"Home"];
[self presentViewController:hc animated:YES completion:nil];
break;
}
Run Code Online (Sandbox Code Playgroud)
故事板文件名是Main.Storyboard,viewController的id是Profile.
以下是故事板的外观图像:

我目前正在从我的应用程序(android)上传视频,这会导致应用程序崩溃,试图弄清楚如何使其在两端,应用程序和服务器端都高效...在一天结束时它会上传视频但崩溃的应用程序或服务器取决于哪一个内存耗尽.
Stack - Java,改造,Node.js,knox,heroku,amazonS3
对于客户端android :(翻译,java):
休息文件:
@Multipart
@POST("/addMedia")
public void addMedia(
@Part("name") String name,
@Part("categ") String category,
@Part("desc") String desc,
@Part("creatorId") String creatorId,
@Part("isItAPicture") String isItAPicture, //if true it is a picture
@Part("mediaFile") TypedFile mediaFile,
Callback<UserResponse> callback);
Run Code Online (Sandbox Code Playgroud)
创建类文件:
ApiManager.getAsyncApi().addMedia(title, categ, descr, creatorId, String.valueOf(isPictureNotvideo), media, new Callback<UserResponse>() {
@Override
public void success(UserResponse userResponse, Response response) {
\
}
@Override
public void failure(RetrofitError error) {
throw error;
}
});
Run Code Online (Sandbox Code Playgroud)
服务器端(Node.js,heroku,AmazonS3,knox模块)
var s3 = knox.createClient({
key: config.amazonS3.key,
secret: config.amazonS3.secret,
bucket:config.amazonS3.bucketMedia
});
function …Run Code Online (Sandbox Code Playgroud) node.js ×5
mongodb ×4
mongoose ×4
android ×3
javascript ×2
amazon-s3 ×1
backbone.js ×1
express ×1
file-upload ×1
firebase ×1
heroku ×1
ios ×1
iphone ×1
java ×1
listview ×1
objective-c ×1
passwords ×1
pug ×1
storyboard ×1
xcode ×1