我已经构建了一个类似于Snapchat的消息传递应用程序 - 一个用户可以发送另一个用户图片.我正在尝试向应用添加推送通知,以便当从UserA向UserB发送消息时,UserB会收到"来自UserA的新消息"的推送通知.
我一直在研究这几个小时,我觉得我很亲密.
我正在尝试使用Parse发送推送通知.我希望它的工作方式如下:当UserA向UserB发送消息时,还会向UserB发送一条推送通知,其中显示"来自UserA的新消息".我成功地使用Parse网站向使用该应用程序的设备发送推送通知,但是无法在应用程序内(当用户发送消息时)向接收用户的设备成功发送推送通知.
推送通知显然是成功发送的,因为我的Parse帐户显示了我发送的消息.但是,没有消息实际到达目标设备,推送通知列表显示每个推送通知的0个订阅者.

我可以点击其中一个来查看详细信息.

此外,我正在使用分发/生产供应配置文件和证书.
这是我在UserA向UserB发送消息后发送推送通知的代码 - message对象是已上传到Parse的消息,messageRecipients是消息发送到的用户:
// Send Push Notification to recipients
NSArray *messageRecipients = [message objectForKey:@"recipientIds"];
PFQuery *pushQuery = [PFInstallation query];
[pushQuery whereKey:@"owner" containedIn:messageRecipients];
PFPush *push = [[PFPush alloc] init];
[push setQuery:pushQuery];
[push setMessage:[NSString stringWithFormat: @"New Message from %@!", [PFUser currentUser].username]];
[push sendPushInBackground];
Run Code Online (Sandbox Code Playgroud)
这是我的AppDelegate.m相关方法:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Parse setApplicationId:@"[This is where my app Id is]"
clientKey:@"[This is where client Id is]"];
[self customizeUserInterface];
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound];
return YES;
} …Run Code Online (Sandbox Code Playgroud) 我想从Parse接收推送通知并打开List活动并在开始活动之前使用intent.putextra("dataFromParse").我能够接收推送,但只使用以下命令打开MainActivity:
PushService.setDefaultPushCallback(this, MainActivity.class);
ParseInstallation.getCurrentInstallation().saveInBackground();
Run Code Online (Sandbox Code Playgroud)
我希望将此作为默认值,但也应该能够启动List活动.我也试过使用客户接收器,但是我只能在接收推送时直接打开活动,而不是点击它.
manifest.xml文件:
<receiver android:name="com.example.Push android:exported="false">
<intent-filter>
<action android:name="com.example.UPDATE_STATUS" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
Push.java:
public class Push extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
//Start activity
}
}
Run Code Online (Sandbox Code Playgroud)
我不确定的是我应该如何在后台捕获推送,并说当用户单击通知时它应该使用特定的intent.putExtra("dataFromParse")打开List活动.我应该在哪里编码以及如何编码?在MainActivity中,在List活动中,还是在客户接收器上执行其他操作?
notifications android broadcastreceiver push-notification parse-platform
Parse在Yosemite中表现得非常奇怪,saveInBackground声称自己不是PFObject的成员.
var score = PFObject(className: "score")
score.setObject("Mo", forKey: "name")
score.setObject(1, forKey: "scoreCount")
score.saveInBackground()
Run Code Online (Sandbox Code Playgroud)
显然这应该有效,也许这是Xcode 6.0.1或Yosemite GM3(或组合)的问题.要清楚,使用saveInBackgroundWithBlock工作正常.
有没有其他人经历过这个或类似奇怪的错误?
我从Parse.com查询数据并将它们保存在本地Realm数据库(iOS/swift)中.每个对象都有一个唯一的属性(A),但也有一个可能相同的属性(B).避免将具有相同属性B的对象添加到领域数据库中的最有效方法是什么?提前致谢.
我目前正在开发一个小型应用程序项目,以便在iOS上学习并尝试使用react-native.我有一些解析(parse.com)的经验,并希望在新的应用程序中集成解析.目前,我没有问题,包括解析反应原生的js.我可以使用帐户等登录.现在我需要向一定数量的用户(并非所有用户)发送推送通知.
我不明白的是推送通知应如何与react-native和parse一起使用.通常,我会使用用户ID连接设备安装,然后将推送发送给一定数量的用户(这意味着具有相应安装的设备).本地反应指南(https://facebook.github.io/react-native/docs/pushnotificationios.html#content)没有提到类似的内容.即使它提供了解析指南作为参考,我也看不出我应该如何能够通过解析发送推送.该指南也留下了许多需要的信息.这些"听众"订阅的来源是什么?我将从哪个服务器发送通知等?
据我了解,解析js无法读取当前安装.我也不愿意将Parse iOS添加到项目中.这感觉不自然,不应该是必需的事情,虽然它可以让我阅读当前的安装.(但仍解析js无法注册该安装以订阅推送通知).
在这一点上,我感到有点失落.这条信息(https://news.ycombinator.com/item?id=9271687)告诉我它应该可能以某种方式.我只是想不通如何:(
希望有人可以帮助我.一些建议将得到真正的赞赏.
尝试从中加载一个类Parse,但是一旦我启动它,应用程序就会崩溃!这是代码:
ListView listview;
List<ParseObject> ob;
ProgressDialog mProgressDialog;
ArrayAdapter<String> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_big_board);
new RemoteDataTask().execute();
}
private class RemoteDataTask extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
mProgressDialog = new ProgressDialog(BigBoard.this);
mProgressDialog.setTitle("Parse.com Simple ListView Tutorial");
mProgressDialog.setMessage("Loading...");
mProgressDialog.setIndeterminate(false);
mProgressDialog.show();
}
@Override
protected Void doInBackground(Void... params) {
// Locate the class table named "Country" in Parse.com
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>(
"Country");
query.orderByDescending("_created_at");
try {
ob = query.find();
} catch (ParseException e) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试升级以将我的项目升级到Swift 2,但我坚持以下错误:
上下文类型"AnyObject"不能与数组文字一起使用
这是我的代码:
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) {
let data = UIImageJPEGRepresentation(image, 0.08)
let file = PFFile(data: data!)
PFUser.currentUser()!["Picture"] = [file]
try! PFUser.currentUser()!.save()}
Run Code Online (Sandbox Code Playgroud)
这是问题发生的地方
PFUser.currentUser()!["Picture"] = [file]
Run Code Online (Sandbox Code Playgroud)
非常感谢你的帮助 !!(我是初学者,......)
我正在尝试使用ParseFacebookUtils库登录Facebook并且它运行良好,但是当我启用Proguard文件时,我在Facebook登录活动启动时遇到此异常:
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{my.package.name/com.facebook.FacebookActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.NullPointerException
at java.lang.Enum$1.create(Enum.java:43)
at java.lang.Enum$1.create(Enum.java:35)
at libcore.util.BasicLruCache.get(BasicLruCache.java:54)
at java.lang.Enum.getSharedConstants(Enum.java:209)
at java.lang.Enum.valueOf(Enum.java:189)
at com.facebook.login.LoginBehavior.valueOf(LoginBehavior.java:26)
at com.facebook.login.LoginClient$Request.(LoginClient.java)
at com.facebook.login.LoginClient$Request.(LoginClient.java)
at com.facebook.login.LoginClient$Request$1.createFromParcel(LoginClient.java:2521)
at android.os.Parcel.readParcelable(Parcel.java:2111)
at android.os.Parcel.readValue(Parcel.java:2020)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2321)
at android.os.Bundle.unparcel(Bundle.java:249)
at android.os.Bundle.getString(Bundle.java:1118)
at android.content.Intent.getStringExtra(Intent.java:5145)
at com.google.android.gms.analytics.Tracker$zza.zziJ(Unknown Source:4000)
at com.google.android.gms.analytics.GoogleAnalytics.isInitialized(Unknown Source)
at com.google.android.gms.analytics.GoogleAnalytics$zzb.onActivityStarted(Unknown Source)
at android.app.Application.dispatchActivityStarted(Application.java:219)
at android.app.Activity.onStart(Activity.java:1087) …Run Code Online (Sandbox Code Playgroud) 我正在使用Parse作为我的应用程序.我想查询一个表,其中列设置为指向其他表的指针.这是查询:
ParseQuery query = new ParseQuery("CategoryAttribute");
query.whereEqualTo("categoryId", categoryId);
query.findInBackground(new FindCallback() {
@Override
public void done(List<ParseObject> categoryAttributes, ParseException e) {
if (e == null) {
for (int i = 0; i < categoryAttributes.size(); i++){
String atributeCategoryId = categoryAttributes.get(i).getString("categoryId");
String attributeKey = categoryAttributes.get(i).getString("attributeKey");
String attributeValue = categoryAttributes.get(i).getString("attributeValue");
setCategoryAtributeRow(atributeCategoryId, attributeKey, attributeValue);
}
} else {
Log.d("score", "Error: " + e.getMessage());
}
}
});
Run Code Online (Sandbox Code Playgroud)
所以该categoryId列是指向其他表的指针.其他列工作正常.我试图扫描API和指南,但找不到所需的解决方案.非常感谢帮助!
我的问题: saveInBackground没有用.
原因它不起作用:我将PFObjects存储在NSArray中保存到文件使用NSKeyedArchiving.我这样做的方法是NSCoding通过这个库实现.由于某些我不知道的原因,正在添加其他几个字段并将其设置为NULL.我有一种感觉,这是搞砸了API调用saveInBackground.当我调用saveInBackground第一组对象(之前NSKeyedArchiving)saveInBackground工作正常.但是,当我在第二个对象(之后NSKeyedArchiving)上调用它时,它不会保存.为什么是这样?
保存
[NSKeyedArchiver archiveRootObject:_myArray toFile:[self returnFilePathForType:@"myArray"]];
Run Code Online (Sandbox Code Playgroud)
恢复
_myArray = (NSMutableArray *)[NSKeyedUnarchiver unarchiveObjectWithFile:
[self returnFilePathForType:@"myArray"]];
Run Code Online (Sandbox Code Playgroud)
NSArchiving之前的对象
2014-04-16 16:34:56.267 myApp[339:60b]
<UserToMessage:bXHfPM8sDs:(null)> {
from = "<PFUser:sdjfa;lfj>";
messageText = "<MessageText:asdffafs>";
read = 0;
to = "<PFUser:asdfadfd>";
}
2014-04-16 16:34:56.841 myApp[339:60b]
<UserToMessage:bXHsdafdfs:(null)> {
from = "<PFUser:eIasdffoF3gi>";
messageText = "<MessageText:asdffafs>";
read = 1;
to = "<PFUser:63sdafdf5>";
}
Run Code Online (Sandbox Code Playgroud)
NSArchiving之后的对象
<UserToMessage:92GGasdffVQLa:(null)> {
ACL = "<null>";
createdAt …Run Code Online (Sandbox Code Playgroud) parse-platform ×10
ios ×5
android ×4
swift ×3
objective-c ×2
xcode ×2
java ×1
nscoding ×1
parsing ×1
push ×1
react-native ×1
realm ×1