混合面板推送通知 ios

Mixpanel Push Notification ios

在 Mixpanel Admin 中,在 Notification 下,如果我过滤指定的设备,如下所示 link(基于电子邮件过滤 -> 选择一个电子邮件发送给相应的设备用户)但是 'Your filter returned no matching users' 如果我看到 Mixpanel。我需要在 People Analytics.As 中添加一些东西,这是处理的开始 Notification.I 不知道为什么它不匹配用户。

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

这就是我在 Mixpanel People Analytics 中处理它的方式,它是正确的还是我需要为 People Analytics 做的任何其他事情。

终于找到推送通知的解决方案了,

下 'didRegisterForRemoteNotificationsWithDeviceToken'

混合面板 *mixpanel = [混合面板共享实例];

[混合面板标识:@"123456"];

[mixpanel.people addPushDeviceToken:usertoken];

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

使用 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)
}