Mixpanel推送通知ios

时间:2015-12-23 05:58:00

标签: ios objective-c mixpanel

在Mixpanel管理员中,在通知下,如果我按照以下链接过滤指定的设备(基于电子邮件的过滤器>选择一个电子邮件发送给相应的设备用户),但“您的过滤器未返回任何匹配的用户” 如果我看到Mixpanel。我需要在People Analytics中添加一些内容。因为这是处理Notification的开始。我不知道为什么它不匹配用户。

 [[Mixpanel sharedInstance] .people set:@{@"Email":[pre objectForKey:@"SignInUserEmailId"]}];

这就是我在Mixpanel People Analytics,Is It Right或我需要为People Analytics做的其他事情的方法。

2 个答案:

答案 0 :(得分:0)

最后我得到了推送通知的解决方案,

在'didRegisterForRemoteNotificationsWithDeviceToken'

Mixpanel * mixpanel = [Mixpanel sharedInstance];

[mixpanel identify:@“123456”];

[mixpanel.people addPushDeviceToken:usertoken];

你的addPushDeviceToken函数将处理$ union操作。在该示例中,“123456”将是您正在注册该推送令牌的不同ID的示例。如果您想在设备上使用当前的不同ID,您可以[mixpanel identify:mixpanel.distinctId]

答案 1 :(得分:0)

使用Swift推送通知。将以下代码放在AppDelegate.swift文件中

如果应用程序最小化,您也可以在代码和设备上接收通知。

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.        

    let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
    UIApplication.sharedApplication().registerUserNotificationSettings(settings)
    UIApplication.sharedApplication().registerForRemoteNotifications()
    return true
}

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {

    //pass the project token from mixpanel account
    let mixpanel = Mixpanel.sharedInstanceWithToken("4e35256cfd95a9b236936bcf0104bb92")

    mixpanel.identify("564") //564 is the unique distinct id of user
    mixpanel.people.set(["name": "your name", "$email": "email@email.com", "Plan": "Free", "$region" : "Australia"])
    mixpanel.people.addPushDeviceToken(deviceToken)        
}

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {

    var alert1: String = ""        
    if let aps = userInfo["aps"] as? NSDictionary {
        if let alert = aps["alert"] as? NSDictionary {
            if let message = alert["message"] as? NSString {
                //Do stuff
            }
        } else if let alert = aps["alert"] as? NSString {
            print(alert)
            alert1 = alert as String
        }
    }        
    let alertController = UIAlertController(title: "Notification", message:
        alert1, preferredStyle: UIAlertControllerStyle.Alert)
    alertController.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.Default,handler: nil))

    UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController(alertController, animated: true, completion: nil)
}